Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 am using GNU bash as my shell on Linux:

$ bash --version
GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

It acts very strangely when I am setting an environment variable with a FS path as its value.

Say I want to add /opt/database/bin to the front of PATH.

I start by typing in:

$ export PATH=/o

Then I press the tab key on my keyboard.

But instead of completing the path to /opt, it deletes the PATH= part! Instead, I get:

$ export /opt/

That is, of course, extremely useless to me and very aggravating! I am then required to add in the environment variable name manually, which is not at all what I wish to be doing!

I wanted it to complete it to this:

$ export PATH=/opt/

Then I can complete the rest of the path using minimal typing and the tab key.

Is there any way that I can get it to not delete the environment variable, and to act in a sensible way that helps make me productive to the max?

share|improve this question
I tried than on a few versions of Bash including 3.2.25, 4.0.33, 4.1.2, 4.2.28 and 4.2.37 and I don't see that behavior. It works for me as you'd expect. Do you have Bash-Completion or any other completion functions in effect? Also, were you doing completion with export PATH=$PATH:/o instead of what you indicated? What distribution of Linux? – Dennis Williamson Sep 9 '13 at 19:08
@Dennis, you are my savior! I did not even realize that Bash-Completion existed, and I did not realize that I had it installed on my Debian! After removing the bash-completion 1:2.0-1 package it is working as I expected it to. Many thanks, sir! – Sara Jones Sep 10 '13 at 1:07
I'll enter it as an answer and you can mark it accepted (and upvote it too, if you like). – Dennis Williamson Sep 10 '13 at 1:12
up vote 2 down vote accepted

Try disabling Bash-Completion.

Your PATH completion works for me, however, on systems using Bash-Completion. You might try un-installing and re-installing it to see if it works. I find the functionality it provides too useful to give up.

share|improve this answer

disabling Bash-Completion altogether has probably been an overkill. It is a very useful and productive feature.

The breakage such as you describe is usually caused by specific bash completion configuration scripts that lie in /etc/bash_completion.d/, installed by third party .deb packages.

I had the exact same problem on Ubuntu, and in my case the culprit turned out to be the /etc/bash_completion.d/npm script installed by the npm Debian package (containing the package manager for Node.js).

I've just moved the npm script out of /etc/bash_completion.d/ - problem solved, and useful Bash Completion functionality preserved.

share|improve this answer
BTW, I've reported the issue in this particular script: – Aleksander Adamowski Jan 22 '14 at 15:43

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.