-
Notifications
You must be signed in to change notification settings - Fork 37
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
How to apply the same functionality to its aliases? #6
Comments
Usually when a command needs to be completed with the same completion just like a different command, you use zic-completion-cl () {
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
local tokens cmd
tokens=(${(z)LBUFFER})
cmd=${tokens[1]}
if [[ "$LBUFFER" =~ "^\ *c[ld]$" ]]
then
zle ${__zic_default_completion:-expand-or-complete}
elif [[ "$cmd" =~ "c[ld]" ]]
then
_zic_complete ${tokens[2,${#tokens}]/#\~/$HOME}
else
zle ${__zic_default_completion:-expand-or-complete}
fi
}
zle -N zic-completion-cl
bindkey "^I" zic-completion-cl I have just created a sister function to Having this kind of customization ability built in with the code should require more work but you can use this as a workaround in the meantime.. |
@doronbehar Is there an easy way to generalize this and replace zsh's completion menu with a menu implemented on top of fzf for any command that uses zsh menu? fzf is so great that I'd like to use it in every command that can display a menu with candidates. Is that archievable in zsh? |
Well TBH, I stopped using zsh-interactive-cd after I realized what it does and after I figured out how to produce it's functionality it along with what the features the other ZSH related files that https://github.com/junegunn/fzf offers (key-bindings.zsh and completion.zsh) under it's own domain. Thanks for being interested in this subject. To be frank, I'm really proud of my ZSH fzf related configuration and that's why I wrote an article about it in my website: https://doronbehar.com/articles/ZSH-FZF-completion/ . |
Yes, my question is not really related to this repo specifically, but it's related to the topic of the issue. I've read your post. Franky, I have shallow understanding of how zsh (and zle) works and I may be wrong, but you seem to be doing pretty much similar things which are described in fzf wiki, e.g.: https://github.com/junegunn/fzf/wiki/Examples-(completion)#zsh-complete-hg-updatehg-merge With this approach the downsides are:
I was wondering whether fzf could be plugged everywhere transparently? What I mean is that interactive menu completion in zsh can be enabled as follows:
I wish there were some alternative with fzf, e.g. |
I guess you are right. I think that this kind of integration might be worth the effort to be merged into the main ZSH repository. But I assume that it would require a lot of work to make it safe and configureable even for users of other fuzzy selection programs such as https://github.com/jhawthorn/fzy for example or other alternatives. Just for the sake of clearance for everyone who may read this discussion: I think the main reason a fuzzy selector might be even more usable if used from within the completion system of ZSH, is that currently, using the widgets mechanism of ZSH, the interpretation of what available options there are for completion is done separately from the completion system. And considering how much effort has been put to make command completions extremely useful (take |
for example, if I have an alias cl:
alias cl='cd $@; ls -a'
how can I apply the same functionality to 'cl', i.e. fzf pops up when pressing after $ cl?
The text was updated successfully, but these errors were encountered: