Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore a path entry with bash tab-completion

I have two commands, foo and foo-bar, where foo is a symlink to foo-bar. I want to be able to type f+TAB (pretend these are the only two commands on the path that begin with f) and have one of them be completed (meaning the full name and the space after).

What ends up happening though is that it completes to just foo (no space) because of foo-bar. It's obviously not much work to then just hit the space bar, but this interrupts my flow.

Some additional details:

  • foo and foo-bar are in the same directory.
  • Deleting/moving foo isn't an option (I've hidden some details).

Is there a way to ignore a specific path entry?

like image 828
Ed Mazur Avatar asked Feb 09 '10 00:02

Ed Mazur


People also ask

How to make bash completion case insensitive?

It can be enabled for all future bash sessions by putting set completion-ignore-case on into the users's ~/. inputrc file, or the system /etc/inputrc , to enable it for all users.

Does bash have tab completion?

Bourne shell and csh do not, but ksh, bash, tcsh, and zsh all have tab completion to varying degrees. The basic principle in all of these shells is the same; you type the start of the word, hit the <TAB> key twice, and the list of possible commands or files is displayed.


2 Answers

You use FIGNORE, although it has some strange properties.

FIGNORE requires a proper suffix. So to ignore foo-bar, any of these will work:

FIGNORE=bar
FIGNORE=-bar
FIGNORE=r
FIGNORE=oo-bar

The import thing is not to try FIGNORE=foo-bar since it's not a proper suffix.

like image 128
R Samuel Klatchko Avatar answered Sep 24 '22 08:09

R Samuel Klatchko


Give this a try:

FIGNORE=foo-bar
like image 38
Dennis Williamson Avatar answered Sep 23 '22 08:09

Dennis Williamson