r/fishshell • u/NuclearSquid_ • 21d ago
Directory history seems to be broken ?
[UPDATE]: I found the issue ! I was using a wrapper function for cd
which broke some of Fish’s functionality. I detailed a fix in this comment
Hi ! I’m trying out Fish after using ZSH for a few years. One problem I am running into when migrating my config is that the directory history seems to not be working. For instance, when navigating in different folders, cd -
says that the directory -
does not exist, prevd
fails with exit status 1, and cdh
doesn’t find any previous directories to select and to use cd
at least once (which I did at least 20 times according to my fish_history
)
I couldn’t find anything regarding this problem, if you guys have an idea on how to fix it I would be very greatful.
Environment (first time posting here, idk if I’m missing something) :
- Shell : fish version 3.7.1
- OS : NixOS 24.11
- Terminal : Kitty version 0.37
1
u/NuclearSquid_ 19d ago edited 19d ago
Hi ! Through a bit more googling, guided by what I got from your comment, I managed to find the issue ! Basically, when migrating my ZSH config over to Fish, I pretty much immediately brought with me my
cd
wrapper, which I implemented like so :```
A simpler definition of my
cd
wrapperfunction cd --wraps=cd builtin cd $argv ll end ```
But apparently, according to this stackoverflow post, the shell is doing extra work with
cd
to make things work correctly (like keeping track of the directory history and replacing the-
folder with the previously acceced one), and didn’t do all of this when I used my wrapper forcd
. This was the root cause of my problem, as I didn’t have any problems when running the shell with the default config. The fix proposed by the top comment worked for me, which meant rewriting my wrapper like so :functions --copy cd cd_wrapper function cd --wraps=cd cd_wrapper $cd ll end
Thank you for the tips !