Command line prediction
6,494
Solution 1
Zsh comes with the insert-and-predict
¹ edition widget, which makes it suggest completions spontaneously based on your command history.
¹ info -f zsh --index-search=predict-on
or LESS=$LESS+/predict-on man zshcontrib
on your machine.
To try it out:
autoload predict-on
predict-toggle() {
((predict_on=1-predict_on)) && predict-on || predict-off
}
zle -N predict-toggle
bindkey '^Z' predict-toggle
zstyle ':predict' toggle true
zstyle ':predict' verbose true
And use Ctrl-Z to turn on or off.
Solution 2
I've successfully used fish-shell.
Seee also Make zsh completion show the first guess on the same line (like fish's)
Related videos on Youtube
Author by
ts01
Updated on September 18, 2022Comments
-
ts01 almost 2 years
I've found an interesting paper: Predicting UNIX Command Lines about command-line prediction (based on user past activity), and I wonder if any actual implementation of such thing exists?
-
peterph over 11 yearsIt seems that this only uses history to offer what you have typed last time, that had the same beginning. Pretty much like
^R
in bash. -
Stéphane Chazelas over 11 years@peterph, That's what the documentation may let you think on a quick read but it goes beyond that and is very customisable. However I find it too annoying/intrusive to be usable (but maybe because I didn't spend (enough) time trying to tune it)
-
peterph over 11 yearswell, I guess this is a feature, that only gets useful for just a couple of repetitions. For anything more, either
alias
or a script are better. Unless it would of course really do some analysis on the commands to determine e.g. what arguments in subsequent commands correspond to each other (which the paper actually mentions as well). -
Admin about 5 yearsCan I turn it off using a simple command? I dont want to bind anything to a key I just want to turn the thing off