Sunday, June 15, 2008

How to disable tilde expansion on bash, Ubuntu 8.04 (hardy)

This is how to prevent bash from replacing "~" with "/home/" when you auto-complete using .

1) Edit .bashrc
prompt%> cd
prompt%> vi .bashrc


2) Add the following lines:

# Disable Tilde Expansion
_expand()
{
return 0;
}

3) Try it out on a new terminal


For those interested, see: /etc/bash_completion Look for "tilde".

References:
* http://www.linuxquestions.org/questions/linux-software-2/how-to-stop-bash-from-replacing-with-homeusername-643162/

2 comments:

Anonymous said...

Thanks, was really annoyed by the automatic expansion :)

Anonymous said...

Better to use:

_expand() {
eval cur=$cur
}

To keep auto-completion of e.g. "unzip archive.zip".