5

Friends,

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 <http://gnu.org/licenses/gpl.html>

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?

Sara Jones
  • 53
  • 2
  • 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](http://bash-completion.alioth.debian.org) 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 09 '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 01: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 01:12

2 Answers2

2

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.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
2

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.