How to enable autocomplete in iTerm2

Viewed 67813

Let's say I'm in my root directory, and I have a User folder that I can cd into. In my default Mac terminal, I can just type cd U + tab, and it autocompletes to cd Users/. How do I get this to work in iTerm2?

It used to work just fine in iTerm2, but I must have changed a setting somewhere that disabled it, and I cannot figure out how to get it back.

7 Answers

Autocomplete in iTerm2 activates by pressing cmd + ;

Steps to add a keybinding for the TAB key:

  1. CMD + , to enter preferences
  2. open tab Keys
  3. in bottom left: add a Key Binding by clicking on the "+" button
  4. click on area to record key
  5. hit TAB key to record it

Then in column Action click on "Select Menu Item" and then on the next drop down select "Ppen Autocomplete" under the session section.

I changed it using these settings:

screenshot

In Iterm 2 , you can activate Autocomplete by pressing command ⌘ + ;

Autocomplete

Autosuggestions while you type a command in Iterm2 (I believe this is what you where referring to)

Git Clone the zsh-autosuggestions plugin in the OhMyZsh plugin folder. (or just brew install it if on Mac)

$ sudo git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Once that is done, add the plugin in the ~/.zshrc file's plugin list.

plugins=(zsh-autosuggestions)

You can also enable Auto Command Completion (View > Auto Command Completion) which shows a window with command completion suggestions as you type. You'll have to have shell-integration enabled first, otherwise it will be greyed out in the menu bar.

https://iterm2.com/documentation-shell-integration.html

Anyone looking for the answer when using zsh, add autoload -Uz compinit && compinit to your .zshrc file.

open ~/.zshrc

or

nano ~/.zshrc

or if you are feeling lazy

echo 'autoload -Uz compinit && compinit' >> ~/.zshrc && . ~/.zshrc
Related