Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I understand that .DS_store files serve a purpose. That said, they are a nuisance when auto-completing with the cd command. When I type cd in Terminal and press tab twice it lists all directories in the working directory.

Is there a way of removing .DS_store from this auto-complete directory listing in the terminal?

share|improve this question
    
When I type cd in Terminal then key Tab twice: there's a prompt before all possibilities (not only directories) are listed. –  Graham Perrin Nov 13 '12 at 1:16
    
That's seems like better behaviour; Do you know how to prevent listing of files when double tabbing after cd? –  Jeromy Anglim Nov 13 '12 at 1:23
    
cd */ followed by two tabs lists all subdirectories of the current directory. But you have to backspace to select one... –  lhf Nov 13 '12 at 1:38
    
@lhf Thanks. It's good to have that option. It would be better if cd was smart enough to only list directories by default. –  Jeromy Anglim Nov 13 '12 at 1:45

3 Answers 3

up vote 5 down vote accepted

export FIGNORE=DS_Store works for me.

The GNU Bash manual provides extensive information on programmable completion.

Specifically, from the documentation on bash variables

FIGNORE [is a] colon-separated list of suffixes to ignore when performing filename completion. A file name whose suffix matches one of the entries in FIGNORE is excluded from the list of matched file names. A sample value is ‘.o:~’

If you are concerned that there might be existing suffixes in FIGNORE, then you can use:

export FIGNORE=$FIGNORE:DS_Store
share|improve this answer

I think what you're really looking for is context-aware tab completion for Bash commands. For example, .DS_Store is a regular file, not a directory, so it should not show up as a possible completion to cd.

The package that solves this problem is called bash-completion. I use Fink's version (fink install bash-completion), and it's also available from MacPorts (port install bash-completion) and Homebrew (brew install bash-completion).

After the package is installed and configured in your .bashrc or .bash_profile, regular files will no longer show up as completions for cd, and many other common bash commands become context aware as well (eg. gunzip).

share|improve this answer

I would use this command:

zip -r foo.zip foo -x "*.DS_Store"

Found here: http://superuser.com/questions/198569/compressing-folders-on-a-mac-without-the-ds-store

share|improve this answer
    
How does this solve the problem of removing .DS_Store from autocomplete? –  grgarside Jul 27 at 19:21
    
Well, actually it does not. But I stumbled upon that page while searching for "mac zip without .DS_STORE". So I thought that maybe it could help someone else. It's probably a bad idea though. –  ling Jul 28 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.