Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't seem to get fish completions working #288

Closed
max-sixty opened this issue Oct 25, 2021 · 8 comments
Closed

I can't seem to get fish completions working #288

max-sixty opened this issue Oct 25, 2021 · 8 comments

Comments

@max-sixty
Copy link

I realize this is going to be a somewhat difficult issue to manage, because it's mostly "doesn't seem to work on my computer". But I tried to figure out what was going on for 15 minutes and couldn't manage, so thought I might not be the only one.

I can't seem to get fish completions to work. I've tried disabling my config.fish file and running zoxide init fish | source in a new shell, but no luck.

I'm running zoxide v0.7.8. __zoxide_zi returns lots of results. __zoxide_z_complete exists in my shell.

Is there anything else I could try?

Thank you!

@ajeetdsouza
Copy link
Owner

ajeetdsouza commented Oct 25, 2021

What version of fish are you using? Does upgrading to the latest version help? What's the output of __zoxide_z_complete?

You can use complete -c z -e to disable the completions (and get the default completions back) for now.

@max-sixty
Copy link
Author

(sorry for the lack of response, I lost control of my GH notifications...)

I'm on the latest fish 3.3.1

__zoxide_z_complete shows an error:

❯ __zoxide_z_complete
test: Missing argument at index 3
= **
     ^
- (line 65):
    if test (string sub -s "-$trigger_length" $line[-1]) = $trigger
       ^
in function '__zoxide_z_complete'

...which I think is because $line isn't getting filled by set -l line (commandline -op). But I think that may just be because it's being run manually?

Regardless, setting interactive=1 and commenting out this section makes the whole thing work.

          set -l interactive 1
          # if test (string sub -s "-$trigger_length" $line[-1]) = $trigger
          #     set line[-1] (string sub -e "-$trigger_length" $line[-1])
          #     set interactive 1
          # end

I can make this change on my setup. Do you think it's just a peculiarity with my setup or something more general?

@ajeetdsouza
Copy link
Owner

@max-sixty just wanted to clarify how completions are supposed to work:

z is designed as a superset of the cd command. As a result, if there is only one argument, you will see the same completions as cd. If the single argument ends with ** or if there is more than one argument, z will understand that you want to "jump" and open up fzf for interactive selection.

So,

z foo<TAB> # no match found, there's no folder starting with foo in the current folder
z foo**<TAB> # opens up fzf, where you can select /tmp/foo
z foo <TAB> # notice the space before <TAB> -- this is the second argument. opens up fzf, where you can select /tmp/foo

Can you verify that the completions are working as designed? In a future release, I'm planning on making the trigger='**' variable customizable. That way you can set it to trigger='' to always get interactive selection.

@ajeetdsouza
Copy link
Owner

Now that you mention it, I think I understand that this is confusing behaviour. Perhaps we should change this to only show interactive completions if you have a ** at the end of your query?

@max-sixty
Copy link
Author

Ah, I see @ajeetdsouza , thanks a lot for clarifying. I was reading the initial comment in #212, and now see that the functionality was changed during the review, as the final comment states

Now that you mention it, I think I understand that this is confusing behaviour. Perhaps we should change this to only show interactive completions if you have a ** at the end of your query?

I guess that often people are using z as a cd replacement, and so without some suffix / trigger they want to complete on the current directory (like cd does), rather than doing a search with z? That makes sense if so.

For me, having the z foo <TAB> complete is great — I didn't realize that was an option. I would not use the ** (would others, rather than just space?). This works on my system.

I'll close this because you answered my question. Thanks again, both for this and for the excellent tool!

@ajeetdsouza
Copy link
Owner

I would not use the ** (would others, rather than just space?)

I suppose you're right. I was actually trying to imitate fzf's completions: https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh

But I suppose completing only after a space is actually a great option that would work on all shells. There's no need of ** then, I'll close this issue once I've removed it. I'll add in some documentation too.

@ajeetdsouza
Copy link
Owner

Released in v0.7.9.

@max-sixty
Copy link
Author

Thank you @ajeetdsouza !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants