Farid
Farid

Reputation: 1665

How to enable autocomplete in iTerm2

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.

Upvotes: 53

Views: 118666

Answers (8)

adisco
adisco

Reputation: 1

If you are looking to mirror the key behavior that is used in terminal.app (e.g. tab to autocomplete, opt+arrow to jump words, etc.) you can achieve this in the Profile pane of the settings.

Go to the Key Mapping tab in Settings > Profiles > Keys and choose "Terminal.app Compatibility" from the presets in the lower left corner.

Upvotes: 0

Progreg
Progreg

Reputation: 401

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

Upvotes: 38

Lucian Murmurache
Lucian Murmurache

Reputation: 124

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

Upvotes: 0

David Mitchell
David Mitchell

Reputation: 81

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

Upvotes: 7

Sanchez
Sanchez

Reputation: 183

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)

Upvotes: 15

Nikhil Kumar Agrawal
Nikhil Kumar Agrawal

Reputation: 724

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

Autocomplete

Upvotes: 21

Shersh
Shersh

Reputation: 9179

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

Upvotes: 23

leealex
leealex

Reputation: 1593

Autocomplete in iTerm2 activates by pressing cmd + ;

Upvotes: 81

Related Questions