11

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?

8

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.

  • It 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. – peterph Nov 21 '12 at 22:30
  • @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) – Stéphane Chazelas Nov 21 '12 at 22:33
  • well, 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). – peterph Nov 21 '12 at 23:00
  • Can 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 – Three May 3 at 20:43
1

I've successfully used fish-shell.

Seee also Make zsh completion show the first guess on the same line (like fish's)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.