48

In Fish when you start typing, autocompletion automatically shows the first autocompleted guess on the line itself.

In zsh you have to hit tab, and it shows the autocompletion below. Is there anyway to make zsh behave more like fish in this regard?

(I am using Oh My Zsh...)

4

3 Answers 3

65

I have implemented a zsh-autosuggestions plugin.

It should integrate nicely with zsh-history-substring-search and zsh-syntax-highlighting which are features ported from fish.

4
  • Highlighting with this doesn't work for me and a number of others and issues on the github don't seem to be addressed. See github.com/tarruda/zsh-autosuggestions/issues/12
    – Eli
    Apr 28, 2014 at 14:53
  • @Eli This plugin has recently been rewritten to address many of the issues. Feel free to give it another shot. Feb 22, 2016 at 14:16
  • Here's the thing about zsh-autosuggestions, it cues off of history which is often similar in effect as tab-completion, but it's entirely different. I think what many of us are looking for is for the exact value that tab would complete to be shown, instead. This is a very significant distinction...
    – Steven Lu
    Oct 3, 2016 at 21:54
  • @StevenLu Tab-completion suggestions have been implemented on a feature branch. Take another look: github.com/zsh-users/zsh-autosuggestions/pull/330 Jun 7, 2018 at 5:15
28

Try:

autoload predict-on
predict-on

See:

info zsh --index-search=predict-on

for details.

3
  • 7
    This is technically the correct answer. However, the zsh predict support is rather abysmal compared to fish as it currently stands (at least with the configurations I tested.) Jul 29, 2013 at 22:36
  • 1
    How do you turn it off?
    – user327359
    May 3, 2019 at 21:03
  • I don't like this at all.
    – surj
    Oct 10, 2019 at 20:49
9

Follow the steps here to get other features as well: https://github.com/abhigenie92/zsh_to_fish

  1. Install oh-my-zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
  1. Clone necessary plugins.
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  1. Add plugins to ~/.zshrc as
plugins = ( [plugins...] zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting)

Note: make sure zsh-syntax-highlighting is the last one in the above list.

  1. Fix background theme issues (Not necessary depends on your theme.) Add the following line to your ~/.zshrc.
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=white'
  1. Restart zsh
source ~/.zshrc

If you like the answer, please consider starring the github repo.

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.