fzf
fzf copied to clipboard
fish: `cd -` doesn't work after changing directory using `ALT-C`
- [x] I have read through the manual page (
man fzf
) - [x] I have the latest version of fzf
- [x] I have searched through the existing issues
Info
- OS
- [x] Linux
- [x] macOS
- Shell
- [x] fish
Problem / Steps to reproduce
After #2799, under Fish sell, I can no longer switch back to the previous directory using cd -
after ALT-C
ing to a directory in the first place. It is working fine under Bash, but not under Fish.
-
fzf --version
:0.33.0 (e03ac31)
-
fish --version
:fish, version 3.5.1
To confirm that it wasn't my environment screwing things up, I did the following:
fish --no-config
source /usr/share/fish/vendor_functions.d/fzf_key_bindings.fish
fzf_key_bindings
fzf-cd-widget
# change to some directory ...
cd -
I can reproduce the problem with fish only, without fzf, like so.
builtin cd /tmp
cd -
# Not going back
pwd
builtin cd -
# cd: The directory '-' does not exist
Looks like builtin cd
of fish does not implement -
for going back. If fish maintainers don't have a plan to implement it, I'm not sure what we should do.
Maybe we could do one of the following:
- Allow a user-defined change-directory command that defaults to the current
builtin cd
. - Set the current directory in a session variable before changing directories, so we have a target to change back to if we want.
What do you think? Thank you!
According to their doc, it looks like cd -
is not going to be a built-in feature of fish.
Fish also ships a wrapper function around the builtin cd that understands cd -
(https://github.com/fish-shell/fish-shell/blob/master/doc_src/cmds/cd.rst#description)
So, I'm just going to remove builtin
from fish version of ALT-C
. It was added along with the bash/zsh version, but maybe it's not necessary for fish.
https://github.com/junegunn/fzf/commit/54841248e7a26ffe545220df2a444e11c96ec757
Thank you.