-
Notifications
You must be signed in to change notification settings - Fork 600
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
Add zsh completion #9
Comments
Could the tab autocomplete be compatible with bash ? Globally I think it should be handled by xoxide independently of the used shell. Side note: I confirm, it is awesome 😍 |
Two things:
|
I think this would be a great feature. I'm not too familiar with setting up shell completions, though, so it might take a while for this feature to land. |
FWIW, although my skills are limited, here is a bash completion I put together. It only completes with zq value (a list would be better) and the options.
|
In the event folks are still looking at this, I've added support for the new query function to the completion The major change is in the catchall (the guts of the completion)
|
@fourjay Perhaps send a PR? |
Related: marlonrichert/zsh-autocomplete has added support for zoxide. |
This should be relatively easy to implement via |
I tried playing around with
So far, I'm still not convinced that this would be a useful feature to have. |
FWIW, I've not been using my attempt (much)
|
Thinking about this a little more, fzf completion fills this role pretty well.... |
If i haven't typed anything, z should work like cd (as it does now) If i've typed something, it should absolutely cycle through top suggestions, pretty please! Guessing what the top suggestion is, and what additional letters to type to get the right one, is no fun. EDIT: Actually listing and not cycling would give me everything i want. Same way cd lists all potential completions. z can do the same, and as long as the top match, the one that will be selected if i press enter, is first, that's all the information i'm looking for. I type: I see:
If i'm looking for |
paste code below in your .zshrc can support z completions _zoxide_zsh_tab_completion() {
(( $+compstate )) && compstate[insert]=menu
local keyword="${words:2}"
local completions=(${(@f)"$(zoxide query -l "$keyword")"})
if [[ ${#completions[@]} == 0 ]]; then
_files -/
else
compadd -U -V z "${(@)completions}"
fi
}
if [ "${+functions[compdef]}" -ne 0 ]; then
compdef _zoxide_zsh_tab_completion z 2> /dev/null
fi |
@fourjay as you suggested, I had a look at how fzf is doing completions, and I think it works quite well for zoxide:
Since fzf already has completions that work like this on a variety of common UNIX commands ( So, for example, if you were in
I think this approach would be the most consistent, since it segregates the completions for @mlncn I've thought about what you described, but I don't think it would work for everyone since I myself often use |
For anyone interested, take a look at #257. I've only implemented Bash completions at the moment, but I'd love to know what you think:
If it works well, we can hopefully write completions for other shells in line with this. For now, you can test it out like so: cargo install --git https://github.com/ajeetdsouza/zoxide --branch bashcomp Update: Fish completions are done too. |
hmm... completions don't seem to be doing anything other than the default for me on zsh. 0.7.5 zinit wait has"zoxide" atinit'eval "$(zoxide init zsh --hook pwd --cmd cd)"' for zdharma/null |
I've just merged support for zsh completions, it will be released in the next version of zoxide. Sorry this took so long, but this is finally an implementation that I'm happy with! # press <space><tab> to start interactive completions.
z foo<tab> # shows the same completions as cd
z foo<space><tab> # shows interactive completions via zoxide |
This doesn't properly work for me like it works for cd. I'm using the following zsh completion: Which allows me to complete the Edit: may be the issue described in #513 |
It would be awesome to tab complete the top rated entries.
Side note: All the tickets are because your tool is awesome :) 🥇
The text was updated successfully, but these errors were encountered: