Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

How can I setup bash completion for the unset command, like when you use echo $XXX, you can get a completion for XXX?

share|improve this question
It seems to work already. – enzotib Dec 31 '11 at 13:22
@enzotib really ? i tried unset TM<tab> and nothing appears , but unset $TM<tab> , which is not the case ... – warl0ck Dec 31 '11 at 13:55
It probably works already with the bash completion package from caliban.org/bash/#completion_download installed. (On Fedora or with EPEL, yum install bash-completion.) – mattdm Dec 31 '11 at 15:10
up vote 2 down vote accepted

You need to turn on bash's programmable completion system. There's a file called bash_completion distributed with bash that you must include from your .bashrc. On typical distributions, put this in ~/.bashrc:

. /etc/bash.completion

If this file is not present on your system, it may be in a separate package from the main bash executable, e.g. bash-completion on Debian.

If you specifically want completion for the unset command, that's

complete -v unset
share|improve this answer

On my Ubuntu/Bash system:

TM1=A; TM2=B
unset TM<ESC><*>
 => unset TM1 TM2  (expands in the command line)  
share|improve this answer

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.