46

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.

Farid
  • 1,557
  • 2
  • 21
  • 35

7 Answers7

72

Autocomplete in iTerm2 activates by pressing cmd + ;

leealex
  • 1,473
  • 1
  • 17
  • 24
  • 6
    That works, thanks! I was hoping I could just use `tab`. For example, `cd vi` + `tab` would give `cd views`. It works that way in terminal, but not in iTerm2. I guess this is good enough for now. – Farid Nov 18 '17 at 14:36
  • That still works, this is a different autocomplete with dropdowns. – kmindspark Oct 01 '20 at 06:20
  • The new binding is `cmd` + `-` + `;` according to https://iterm2.com/features.html – cindyxiaoxiaoli Jan 19 '21 at 16:01
  • 3
    This used to work automatically for me (automatic autocomplete) without typing cmd+; Any ideas why it has stopped doing this? I liked it. – Ashley Aitken Mar 21 '21 at 03:16
  • This does not yield the expected behavior, at least not in a latin-american keyboard layout – ihojmanb Dec 27 '21 at 21:20
27

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

In column Action click on "Select Menu Item", and then on the next dropdown select "Open Autocomplete" under the session section.

I changed it using these settings:

screenshot

Community
  • 1
  • 1
Progreg
  • 291
  • 3
  • 3
22

You can install bash-completion package to autocomplete by Tab key.

Shersh
  • 9,019
  • 3
  • 33
  • 61
18

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

Autocomplete

12

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)
Sanchez
  • 153
  • 1
  • 6
5

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

0

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