Comments (5)
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 git
's completion for example) it would be insane to re-implement it in separate functions binded to widgets that they collect the available options of completion and just launch fzf
(and not the _complete
function for example). Therefor it would be much better to make the existing completion functions launch fzf
if available and if it is configured with zstyle
.
from zsh-interactive-cd.
Usually when a command needs to be completed with the same completion just like a different command, you use compdef _cd cl
but it doesn't work since is not a completion plugin but a zle
widget. As far as I understand the code, the widget is defined with check for cd
hard-coded when the widget is defined. Try this:
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 zic-completion
like the origin and I replaced the hard-coded conditions that check the current command line arguments against cd
so cl
will be checked as well.
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..
from zsh-interactive-cd.
@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?
from zsh-interactive-cd.
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/ .
from zsh-interactive-cd.
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:
- you need to have a wrapper for each command that you want to power up with fzf
- it gets uglier when you want to support subcommands (e.g.
hg up
,hg merge
) - I guess it gets even worse than that if you want to support flags/arguments (e.g.
hg diff --rev <cursor>
)
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:
zstyle ':completion:*' menu select interactive
I wish there were some alternative with fzf, e.g. menu select fuzzyinteractive
which would call fzf or exhibit similar visual behavior without any additional bindings but with the default TAB. I'm afraid that to do that, one would need to go down the rabbit hole and implement it in zsh (in C).
from zsh-interactive-cd.
Related Issues (12)
- Case insensitive support HOT 7
- line 140: `zic-completion': not a valid identifier HOT 3
- Work with autocd ?
- newb question HOT 1
- newest version not used my oh-my-zsh HOT 2
- .* and * HOT 3
- May I ask how to make the demo GIF
- doesn't work with BSD sed (assumes GNU sed) HOT 1
- would be nice if it works with hashed directories
- An option so that you do not have to press <tab> (ever) HOT 1
- interactive-cd conflicts with cd -<tab> HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zsh-interactive-cd.