Open elkarouh opened 2 years ago
Hi! There's a builtin command :pwd
that will output the default-directory
but you can also use :ev default-directory
to see the variable's current value.
This is the problem.
$:pwd
does not always return the same result as
$pwd
I tried
:shell-resync-dirs
to reset Emacs' pwd to the shell's pwd but it is not recognised.
Is it the right syntax?
Fwiw, i use ksh.
Regards
Ah, this is because the builtin shell (from shell.el) has directory tracking that is not always 100% accurate. It can lose track for example if you use unconventional commands to change directories. There's a builtin function shell-resync-dirs
that will attempt to set the value of default-directory
to the correct value.
One example of this is I use z
to hop to directories which of course shell.el can't keep up with. shx has a variable to help out with this a bit -- in the case of z
you can (setq shx-directory-tracker-regexp "^z ")
and then shx will attempt to run shell-resync-dirs
whenever the command matches the given regexp.
Hopefully that helps, but let me know!
I missed the part where you wrote this:
:shell-resync-dirs to reset Emacs' pwd to the shell's pwd but it is not recognised. Is it the right syntax?
If you want to run this command it's bound by default to M-return or M-x shell-resync-dirs -- :shell-resync-dirs
won't work.
When changing directory, i ran the command :eval (getenv "PWD") and it returns the original directory at shell creation. How can i get the current directory when in shx mode?