Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 9 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:

share|improve this answer
Not sure about you, but it had to be $FIGNORE:.DS_Store on mac for me. Didn't work without the "." – typeoneerror May 20 '15 at 18:38
@typeoneerror, same for me. Perhaps in the past it worked as posted. Thanks for letting me know. – lhf May 20 '15 at 19:10

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 -x "*.DS_Store"

Found here:

share|improve this answer
How does this solve the problem of removing .DS_Store from autocomplete? – grgarside Jul 27 '14 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 '14 at 20:03

Your Answer


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.