28

Is there a way to do the type of auto-suggestion Fish does in Zsh?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Eli
  • 36,793
  • 40
  • 144
  • 207
  • 2
    Yes I have implemented this feature for zsh, see [this answer](http://unix.stackexchange.com/a/99306/31392) for more details. – Thiago Padilha Nov 07 '13 at 23:22
  • See answers on "Unix and Linux" http://unix.stackexchange.com/questions/84844/make-zsh-completion-show-the-first-guess-on-the-same-line-like-fishs and http://unix.stackexchange.com/questions/56281/command-line-prediction – lrkwz Mar 21 '14 at 10:06

2 Answers2

27

https://github.com/tarruda/zsh-autosuggestions does exactly what I wanted. If you want fish-style autopredictions in zsh, use that.

Eli
  • 36,793
  • 40
  • 144
  • 207
17

Zsh has predict, run the commands below this and then hit Ctrl-X 1 or just type predict-on to give it a try

#-*-shell-script-*-
autoload predict-on
autoload predict-off

# you may also wish to bind it to some keys...
zle -N predict-on
zle -N predict-off
bindkey '^X1' predict-on
bindkey '^X2' predict-off
Francisco
  • 3,980
  • 1
  • 23
  • 27
  • 1
    This is great, but it takes over my tab key and isn't colored like in Fish. Can you add ways of doing/fixing those, and then I'll accept your answer? – Eli Jun 24 '13 at 19:29
  • 2
    I do not use colors in the input part of the shell (as opposed to the output of commands like `ls`), and I'm not about to research that for you :-P, with regards to TAB, I'm not sure what you mean. Perhaps we have different expectations, but TAB stills works in the same way as before for me when predict is on. Try using it `zsh -f` to make sure it is not some interaction with some other shell config of yours. – Francisco Jun 25 '13 at 08:29