justinmayer / virtualfish

Fish shell tool for managing Python virtual environments
MIT License
1.06k stars 100 forks source link

`vf ls` affects `cd -` #167

Closed hofstee closed 4 years ago

hofstee commented 4 years ago

If I do vf ls followed by cd -, I will end up in .virtualenvs. It would be nice if it didn't modify my directory stack.

~ · cd temp
~/temp · cd -
~ · vf ls
python3
~ · cd -
~/.virtualenvs · 
justinmayer commented 4 years ago

Thank you for reporting this, Teguh. This is a side effect of using pushd and popd to get the list of virtual environments, which creates entries in the directory history, as visible in the $dirprev variable. I'm sure there are more elegant solutions, but in 6eb481e I added commands to remove those directory history additions when pushd and popd are used. I released that fix in VirtualFish 2.1.1.

If anyone finds this and cares to make this fix more Fishy™, I imagine there's a way to remove the pushd, popd, and sed calls, and replace them with something like:

for i in $VIRTUALFISH_HOME/*/bin/python
    basename (string replace '/bin/python' '' $i)
end

When I tried that, however, execution was 4x slower than the existing method, so I left it for now.

hofstee commented 4 years ago

Thank you for fixing it so quickly!