Usually on a Unix/Linux terminal when you press Tab it will auto-complete until there are several options, and then it will list the options below for you to select. For example:
cd hehelpFolder/ helpMe/ heIsThere/cd help
With the Mac terminal, it forces you to press it twice to see options. I wondering if it's possible to change that setting to one Tab press?
Best Answer
- Type in terminal
nano ~/.inputrc
Paste the following on separate lines
set completion-ignore-case onset show-all-if-ambiguous onTAB: menu-complete
- Hit Control+O to save changes to .inputrc followed by control+X to quit
- Open a new Terminal window or tab, or type “login” to open a new session with the rules in effect
- Type and hit the tab key
Src: http://osxdaily.com/2012/08/02/improve-tab-completion-in-mac-os-x-terminal/
Put this in your ~/.inputrc
:
set show-all-if-ambiguous on
You'll need to restart your shell (for example by opening a new terminal window or typing exec /bin/bash
).
I am adding a new answer because in my case adding the line set show-all-if-ambiguous on
was not enough.
I had also to remove the line: TAB: menu-complete
.
My complete ~/.inputrc
file is the following:
set completion-ignore-case onset show-all-if-ambiguous on
What you want to change is the Bash shell setup. My OS version is 10.11.6 and I use mvim, here just vim or vi,if the ~/.inputrc does not exist, then you need create a new one.
- In terminal type
vim /.inputrc
. The variable of completion-ignore-case and show-all-if-ambiguous need to be enabled to be ON, this is done by paste those settings in two lines,
set completion-ignore-case on
andset show-all-if-ambiguous on
Add
TAB: menu-complete
and write&quit the vim. :wq- Quit the Terminal running, Command+Q.
- Start Terminal again and verify the result.
Looks like the other comments are for bash
whereas MacOs moved already to zsh
as default shell. To enable autocompletion (including subcommands), putting the following line in zsh
config file (~/.zshrc
) works for me:
autoload -Uz compinit && compinit