Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac Terminal Auto Complete

Tags:

terminal

macos

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 he
helpFolder/ 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?

like image 607
user1334858 Avatar asked Jun 20 '15 19:06

user1334858


People also ask

How do I turn on autocomplete on Mac?

In the Safari app on your Mac, use AutoFill settings to fill in contact information, user names and passwords, credit card information, and other forms on webpages. To change these settings, choose Safari > Settings, then click AutoFill.

How do I turn on auto command completion?

Using autocomplete is as simple as pressing the [TAB] and the active command line options will fill-in. If more than one option is available, you can hit [TAB] twice to display all possible choices and continue typing until there is only one matching choice left.


3 Answers

  1. Type in terminal nano ~/.inputrc
  2. Paste the following on separate lines

    set completion-ignore-case on
    set show-all-if-ambiguous on
    TAB: menu-complete
    
  3. Hit Control+O to save changes to .inputrc followed by control+X to quit
  4. Open a new Terminal window or tab, or type “login” to open a new session with the rules in effect
  5. Type and hit the tab key

Src: http://osxdaily.com/2012/08/02/improve-tab-completion-in-mac-os-x-terminal/

like image 97
andrewoodleyjr Avatar answered Oct 13 '22 16:10

andrewoodleyjr


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).

like image 59
rob mayoff Avatar answered Oct 13 '22 16:10

rob mayoff


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 on
set show-all-if-ambiguous on
like image 13
Francesco Boi Avatar answered Oct 13 '22 17:10

Francesco Boi