Path Completion (bash)

August 10th, 2012

If you upgraded to Mountain Lion and often want to cd into ~/Library/Application Support you might be a little annoyed by the new Application Scripts directory that makes the normal "~/Library/Ap⇥stop at~/Library/Application S‸` to have you disambiguate the path.

To avoid this you can set the FIGNORE variable. From man bash:

    A colon-separated list of suffixes to ignore when 
    performing filename completion (see READLINE below). A 
    filename whose suffix matches one of the entries in 
    FIGNORE is excluded from the list of matched file- 
    names. A sample value is ".o:~".

So if you set this in your bash startup file:

FIGNORE=".o:~:Application Scripts"

Then it will completely ignore that folder and do the full expansion.

Some other useful variables you can set in ~/.inputrc that (IMHO) improve the default behavior of filename completion:

completion-ignore-case (Off)
    If set to On, readline performs filename matching and 
    completion in a case-insensitive fashion.

mark-symlinked-directories (Off)
    If set to On, completed names which are symbolic links 
    to directories have a slash appended (subject to the 
    value of mark-directories).

show-all-if-ambiguous (Off)
    This alters the default behavior of the completion 
    functions. If set to On, words which have more than one 
    possible completion cause the matches to be listed 
    immediately instead of ringing the bell.

So my recommendation is to go with this:

set completion-ignore-case on
set mark-symlinked-directories on
set show-all-if-ambiguous on

The ignore case allows you to type ~/l⇥ and still get ~/Library/.

Marking symlinked directories is useful for /tmp, /etc, and /var.

Showing all when ambiguous instead of ringing the bell… who came up with these defaults?

[by Allan Odgaard]

5 Responses to “Path Completion (bash)”

  1. Joshua Says:
    August 10th, 2012 at 22:41

    I had to use .inputrc instead of .inpurc.

    Thanks for the suggestions.

  2. Allan Odgaard Says:
    August 10th, 2012 at 22:50

    My bad, I corrected the path.

  3. Brian Says:
    September 8th, 2012 at 20:49

    For me, adding FIGNORE to ~/.inputrc causes the capital F key to cause a bell, and the only way to enter it is via filename autocompletion. Any ideas? It did work as to disambiguate the paths as expected, though.

  4. Allan Odgaard Says:
    September 9th, 2012 at 10:03

    Brian: The FIGNORE setting should go into ~/.bashrc or ~/.bash_profile.

  5. Uğur Özyılmazel Says:
    April 5th, 2016 at 08:05

    ooo God! thanx for the FIGNORE tip! awesome!

Leave a Reply