Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWD environment variable doesn't change when changing directory in a shx shell #31

Open
elkarouh opened this issue Mar 3, 2022 · 4 comments

Comments

@elkarouh
Copy link

elkarouh commented Mar 3, 2022

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?

@riscy
Copy link
Owner

riscy commented Mar 3, 2022

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.

@elkarouh
Copy link
Author

elkarouh commented Mar 3, 2022

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

@riscy
Copy link
Owner

riscy commented Mar 5, 2022

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!

@riscy
Copy link
Owner

riscy commented Mar 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants