3

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.

3 Answers 3

2

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.

2
  • 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, 2012 at 13:31
  • The real problem is that I had a directory name ~ in my home directory. See my answer below.
    – crobar
    Nov 1, 2012 at 14:25
2

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

1

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
1
  • 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, 2012 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .