0

Let's say that I have this tree architecture:

~/user
|_____ dir0
|_____ symlink0
|      |_______ somefile0
|_____ symlink1
       |_______ somefile1
       |_______ somefile2

If I'm doing this:

cd
cd symlink0/
cd ../[tab][tab]

I expect it to display the content of ~/user:

dir0 symlink0 symlink1

So I can do something like:

cd ../symlink1/

But instead it is auto-completing directly to...

cd ../dir0/

... with only one [tab] key press.

Any suggestion? Thanks!

EDIT: on another computer it does not autocomplete at all, even with a 'real' directory as in my above example. In the case of multiple directories it is either not autocompleting at all (no proposition of possible directories) or just autocompleting to the first directory, depending on the machine used.

Note that this happens only when trying to reach directories that are above in the tree structure (e.g. cd ./path/to/sym # press [tab][tab] will output symlink0 symlink1 to choose from if ./path/to contains two symlinks.)

2
  • What does it do when there are multiple real directories available?
    – bxm
    Nov 12, 2019 at 13:45
  • @bxm Thanks for your comment, I edited my question for further explanation of the problem.
    – Nolan
    Nov 13, 2019 at 15:06

1 Answer 1

0

The reason is that for the shell, a symlink is a priori only a file, and the fact that it points to a directory is only apparent by inspecting its contents and recognizing that the target is, indeed, a directory. You may have noticed that when starting to type the name of a symlink that points to a directory, the trailing '/' only appears if you press TAB twice.

Since in the setting you presented, there is one actual directory, the autocomplete of cd, which obviously expects a directory as argument, is greedy and takes that one instead of waiting for the interpretation of the symlinks.

You may be able to overcome this behaviour by following advice in this post.

1
  • I actually tried this answer already, but it does not grant cd the ability to autocomplete these symlinks. I think it is important to note that it can autocomplete paths that include symlinks in normal cases (e.g. cd ./path/to/symlink/ # double press [tab] for '/') but not when trying to access symlinks located above the current directory (e.g. cd ../another/path/to/symlink).
    – Nolan
    Nov 13, 2019 at 14:59

You must log in to answer this question.

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