mfaerevaag / wd

:rocket: Jump to custom directories in zsh
MIT License
693 stars 45 forks source link

Bug report: wd does not actually change directories #115

Open synic opened 1 year ago

synic commented 1 year ago

Describe the bug Typing wd <bookmarkname> doesn't actually change directories. Everything seems like it's going to work, but the most important part doesn't seem to do anything.

To Reproduce Steps to reproduce the behavior:

  1. Install wd via zplug on MacOS Ventura
  2. Go to a directory you want to bookmark
  3. Type wd add test
  4. Type wd list to verify that it created your bookmark and that it points to the correct directory.
  5. Type cd ~/ to go to your home directory.
  6. Type wd test.

Expected behavior It should go to the directory you bookmarked

Actual behavior You are still in your home directory. No errors are printed. Nothing happened.

Desktop (please complete the following information):

Additional context It doesn't seem to matter if I am using the version of zsh that comes with MacOS, or the version that is installed with homebrew, it doesn't work for either one.

synic commented 1 year ago

Just a note, I tried it with oh-my-zsh, and it works, so there must be some configuration option I'm missing?

NoiseRay commented 1 year ago

Well sorry for being late to the party, But I have the same "bug" (behavior), it was strange at first, but after reading some of the code I was able of figure it out.

This behavior has nothing to do with the repo itself, wd works perfectly, the issue comes with the plugin manager, in my case "zinit"

The problem is the context in which "shell" runs the script, the subshell is changing the path , but it has its own environment, so it changes the directory and finishes, but it isn't carrying the proper environment so it changes, but not for the main prompt.

That said, you can simply define the function again after the script loads, as indicated by install.sh in line 38

echo "Adding wd function to your ~/.zshrc..."
echo "wd() {"         >> $ZSHRC
echo "  . $DIR/wd.sh" >> $ZSHRC
echo "}"       

You can do it this way after loading the script

wd(){
  . /path/to/wd.sh #there is a space to source it in the current enviroment
}

I solved it in a dirty way (coz im learning about zinit lol) and simple source it wd.plugin.zsh if anyone was wondering how

zinit ice as"program" \
    cp"wd.sh -> wd" mv"_wd.sh -> _wd" \
    src"wd.plugin.zsh"
zinit light mfaerevaag/wd
alpha-tango-kilo commented 1 year ago

I'd be happy to review & merge a PR for new or updated installation steps for zinit/zplug. Especially since we already document how to install zplug, if that method no longer works, then that should be updated or removed