Dear Interweb...

Quick question for the Interweb regarding bash completion. If I do cat ~/[tab], I get to pick from 182 completions, as it lists all of the dotfiles. Is there a way of telling bash to only complete dot files if I put a dot, otherwise only complete non-hidden files? Answers on a postcard, or if you must, a comment on this blog. Thanks!

NP: IBM 1401, a User's Manual, Jóhann Jóhannsson

10:30 Thursday, 18 Jan 2007 [#] [computers] (9 comments)

Posted by skateinmars at Thu Jan 18 10:49:22 2007:
This is not really a solution, but zsh can do it.
Posted by Wouter Bolsterlee at Thu Jan 18 10:54:01 2007:
From the bash manpage:

  match-hidden-files (On)
  This  variable, when set to On, causes readline to match files whose names begin with a
  ‘.’ (hidden files) when performing filename completion, unless the leading ‘.’ is  sup‐
  plied by the user in the filename to be completed.
Posted by Wouter Bolsterlee at Thu Jan 18 10:57:42 2007:
Btw, you have to add this line to ~/.inputrc (don't type it into your shell!) to get it working:

set match-hidden-files off
Posted by David Mills at Thu Jan 18 11:03:42 2007:
You could also try setting GLOBIGNORE to .*, like that the bash auto-path-complete will ignore anything starting with a . . (nb: GLOBIGNORE is a colon seperated list of values, so you could also add other elements in there if you wanted to.

David
Posted by Jim at Thu Jan 18 11:17:55 2007:
shopt can be useful here if you want to do it temporarily. See the 'dotglob' option.
Posted by Ross at Thu Jan 18 11:21:27 2007:
GLOBIGNORE doesn't work, it doesn't effect tab completion.  Wouter's suggestion works, thanks!
Posted by Dave at Thu Jan 18 13:55:26 2007:
Oh, I see someone's already beaten me to the match-hidden-files answer.....

....shame on them  ;)
Posted by skampi at Thu Jan 18 16:40:24 2007:
Oh, I see someone's already beaten me to the zsh answer....
Posted by Wouter Bolsterlee at Thu Jan 18 19:32:49 2007:
Perhaps Ross should do man[space]bash[enter]/hidden[enter] next time ;)

Name:


E-mail:


URL:


Add 8 and 2 (required):


Comment: