supercrabtree / k

k is the new l, yo
1.78k stars 124 forks source link

Calling `k` breaks `cd -` #51

Closed StreakyCobra closed 9 years ago

StreakyCobra commented 9 years ago

Hi,

Thanks for your plugin, it's amazing.

I noticed a small bug annoying for people having the habit of using cd -. It is used to switch back to the previous directory. Your function is using some cd that are not done in a subshell – not within (...) or $(...) – and because of this the shell keep trace of all visited folders within the function.

To reproduce:

  1. Preparation

    mkdir -p ~/TEMPFOLDER
    cd ~/TEMPFOLDER
    mkdir AAA BBB
  2. Normal case

    cd ~/TEMPFOLDER
    cd AAA
    cd -  # Go back to TEMPFOLDER
    cd -  # Go back to AAA
    cd -  # Go back to TEMPFOLDER
    cd -  # Go back to AAA
    # Etc...
  3. Wrong case

    cd ~/TEMPFOLDER
    cd AAA
    cd -  # Go back to TEMPFOLDER -> OK
    k
    cd -  # Go back to BBB -> not what i want...

I tried to look for correcting it, but the construction of the code doing the cd doesn't allow an easy fix, at least up to my knowledge. I can contribute if needed but before taking time on it I decided to open this issue to discuss the best way to solve it.

chrstphrknwtn commented 9 years ago

@StreakyCobra This should be fixed by a483c98c22870001fb2ad6dfb460a155641982ea

StreakyCobra commented 9 years ago

Hum it doesn't seems to solve the problem. But it's a minor one, I can deal with it :-)