Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On my work scientific linux 6.2 machine, I often start typing in a directory like below and use tab completion to finish it:

~/mydir

But when I hit tab, it becomes e.g.

\~/mydirectory/

With an extra forward slash at the start. Why is this, and can I prevent it? It's a pain because using cd etc. doesn't work with the extra slash, I have to start from the actual home directory which is something like

/home/username/

On these PCs.

Edit

Actually this problem did not show up for every directory, only one particular one, which I didn't realise when I asked. The cause of the problem is given in my answer to the question.

share|improve this question
add comment

3 Answers

Linux does not apply any tab completion. The shell does.

The boxes have a mis-configured completion system, or perhaps they mis-apply, for example zsh completion to bash or vice versa.

  1. Try starting another shell (bash, zsh) and sourcing /etc/profile* for that shell
  2. log in without a profile. ssh host.com bash --noprofile --norc

This will help you figure out where the problem lies. I am confident that the problem is in the setup files (profile) of the host or user and that this is not an issue with the shell.

share|improve this answer
    
Thanks, at least you have confirmed that this should not work this way, and is probably a setup problem I can contact the sysadmin about. As you might have guessed, I'm a relatively new Linux user. I will forward your reply to IT now that I know the problem is not me at least. I'll mark this as the answer if they agree. Until then, I would give you an upvote, but don't have enough rep on this site yet. –  crobar Oct 27 '12 at 13:31
    
The real problem is that I had a directory name ~ in my home directory. See my answer below. –  crobar Nov 1 '12 at 14:25
add comment

Read this blog post about installing an utility called bash-completion it's more powerful than the default tab completion code and it's more flexible.

The command completion by the way

Alternatively, When you issue the command:

cd

Without parameters you will cd to your home directory, after that you can simply start to type:

mydir

And when you hit tab, the autocomplete will turn it to

mydirectory
share|improve this answer
    
Thanks for replying though, this is a work PC (or rather a network of many work PCs), so I can't really install whatever I want on it. Your workaround will work for the specific case of cd, but I don't always want to have to change directory to do this. –  crobar Oct 27 '12 at 13:20
add comment
up vote 1 down vote accepted

I had accidentally created a directory named ~ in my home directory. This was the root cause of the problems. Removing this solved them.

share|improve this answer
add comment

Your Answer

 
discard

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.