views:

164

answers:

4

My inputrc is empty. I use Bash.

Problem: I am at

cd $te

I press Tab, and I get

cd \$test

How can you have the tab completion without the backslash in Bash?

+4  A: 

You don't. In Bash, a $ is used in the retrieval of variables. For example:

SWEETVAR='hi'
echo $SWEETVAR

Because of this, a $ in the name of a file or folder must be escaped, else it is interpreted as a var.

Allyn
@Allyn: How can you have a var instead of a system var in Bash, such that you do not need the backslash for escaping.
Masi
You apparently mean with a var an alias.
Masi
+1  A: 

The problem seems to be in MacPorts.

It has an old version of Bash_completion.

The newest version has the following in

complete -o nospace -F _cd cd

while I have the following after executing the command

$complete | grep cd
complete -o filenames -o nospace -F _cd cd

I sent a comment to MacPorts' irc to update bash-completion @20060301 (sysutils).

Masi
A: 

I finally moved to Zsh. It solved the problem for me.

Masi
A: 

I found another way too to solve the problem partially.

  1. update you Bash to Bash 4.
  2. put autocd on by putting the following to your .bashrc

    shopt -s autocd

Then, you can avoid the backslash by not typing cd when you change directory.

Masi