oh-my-fish / plugin-cd

A featured cd can make your fish journey much more pleasant.
https://github.com/sancoder-q/plugin-cd
MIT License
19 stars 5 forks source link

Crash when trying to complete a directory name available in $CDPATH #4

Closed Bounga closed 6 years ago

Bounga commented 6 years ago

Coming from ZSH I am a huge fan of $CDPATH which allow to quickly jump into a directory.

So I did:

set -gx CDPATH . ~/Code

Now when I do cd a_directory_available_in_Code I land in this directory even if I was not in ~/Code directory.

But if I do cd a_direc<TAB> then it crashes with

~/.local/share/omf/pkg/cd/completions/cd.fish (line 1): No matches for wildcard '"$resolved_path"*'. See `help expand`.
command ls -adp "$resolved_path"* | sed 's|.*/\([^/]*.\)$|\1|' | sed "s|^|$base|"
                ^
in command substitution
    called on line 0 of file ~/.local/share/omf/pkg/cd/completions/cd.fish

in function '__fish_complete_plugin_cd'
    called on standard input

in command substitution
    called on standard input

If I remove the cd plugin it does work as expected

ghost commented 6 years ago

I think it has to do with https://github.com/fish-shell/fish-shell/issues/3077 same happens if you want to expand a string in the middle of a name.

Bounga commented 6 years ago

Thank you @kehugter but I'm not sure to understand. Is it fixable at cd plugin level? If not what should I do since the issue you are referring to is closed.

In my understanding, with pristine Fish shell my use case does work (I can complete paths available in my cdpath from anywhere) so the bug is introduced by cd plugin, isn't it?

ki0 commented 6 years ago

Same here

Bounga commented 6 years ago

@SanCoder-Q @masa0x80 any clue about this really annoying bug? I think it prevents any CDPATH user to use the cd plugin.

bryaan commented 6 years ago

yup, it was a very quick omf remove cd for me :(

I don't see how this is related to fish-shell/fish-shell#3077 ?

masa0x80 commented 6 years ago

@Bounga Recently I use replace_multiple_dots.fish plugin instead of plugin-cd, this is a very simple plugin. I think it does not cause crash.

Bounga commented 6 years ago

@masa0x80 It does handle some features I need but it doesn't do cd and cd - that I use a lot too.

Seems like I'll have to learn some Fish scripting, figure out what's happen with cd plugin and try to fix it.

SanCoder-Q commented 6 years ago

@Bounga Does the issue still exists? The recent update released on Jan 3, 2018, should fix the issue. Please try update the plugin and check it out. And so sorry for the late reply. I got some email watching problems, and this issue hasn't be tracked by my mail client. But I fix it just now. I will keep my eyes on it very closely.

Bounga commented 6 years ago

Hi @SanCoder-Q Thank you for your reply. So I just updated. It doesn't crash anymore but I don't have completion at all anymore even for directories / files in the current working directory:

~  cd Do (I tab here and nothing)
~ ls | grep Doc                                                                                                                                         
Documents  

I can jump in directories located in CDPATH if I know its exact name, same as before the fix. The only positive thing of this fix is that hitting TAB doesn't crash anymore but it doesn't do anything…

SanCoder-Q commented 6 years ago

@Bounga Gotcha. I'll try to add the completion ASAP. Thank you.

SanCoder-Q commented 6 years ago

@Bounga I have updated the plugin. And now it got completions with CDPATH support. Let me know if you found more issues. Thanks.

Bounga commented 6 years ago

@SanCoder-Q I tested the new release. You brought back completion for directories / files in the CWD but still don't have any completion enabled for directories in CDPATH:

$ echo $CDPATH                                                                                                                                              
. /Users/nico/Code /Users/nico/Synbioz/Code

$ pwd                                                                                                                                                       
/Users/nico

$ ls /Users/nico/Code/                                                                                                                                      
Icon?             bounga.org        contribs          games             shopit            shopit_api
POCs              cavigneaux.net    dotfiles          ios-to-web-stream shopit-front      training

$ cd trai<tab>
# still does nothing
Bounga commented 6 years ago

Just notice that is does work if CDPATH contains only one element:

$ set -x CDPATH /Users/nico/Code/ 
$ cd cont<tab> #works

As soon as I had another directory, it stop working.

SanCoder-Q commented 6 years ago

@Bounga I will fix it very soon. Thank you for your feedback.

SanCoder-Q commented 6 years ago

@Bounga Please update and try again. 😄

Bounga commented 6 years ago

@SanCoder-Q Yes! You did it. Thank you so much for your work and quick replies. It's going to be so much nicer now CDPATH completion works. I can't thank you enough. Got all the features I needed in Fish now.