Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Terminal Version 2.2.3 (303.2).

The problem is when I try to change directory starting from root, I have to double tab for some directories to get trailing slash.

For example, I start to type

cd /etTab

it gives me:

/etc

Then I have to hit tab once more to get needed trailing slash

/etc/

And then, finally, I can Tab all further directories using single tab hit.

How can I fix this? I miss Ubuntu's bash so much.

share|improve this question
    
Does cd /etc not work under OS/X ? – Hennes Nov 16 '12 at 7:17
    
It does, but I need to access /etc/some/thing for example. And I am used to do it using less tab taps :) – Vitalii Zurian Nov 16 '12 at 7:20
1  
@Hennes Terminal is not a shell is a GUI application which uses the default shell – Matteo Nov 16 '12 at 7:24
1  
Feel free to post that as your own answer. Maybe add a screenshot like this cdn.osxdaily.com/wp-content/uploads/2012/03/… Or check out this on bash completion. gnu.org/software/bash/manual/html_node/… – Hennes Nov 16 '12 at 7:26
1  
Interesting. Usually, mark-directories is set to on in Bash, and should do what you want. See also: Getting compgen to include slashes on directories when looking for files – slhck Nov 16 '12 at 7:37
up vote 8 down vote accepted

This is because, on OS X, /etc is a symbolic link:

$ l /etc
lrwxr-xr-x 1 root 11 2012-09-22 09:02 /etc -> private/etc/

that is, /etc is a file, not a directory.

If you try a real directory, like /usr, you'll see the expected behavior:

cd /us TAB

cd /usr/

You can force Bash to treat symlinked directories as directories with this command:

bind 'set mark-symlinked-directories on'

Add it to your .bashrc and source it (that is, read and execute commands from it) like this:

. ~/.bashrc

or reopen Terminal.

share|improve this answer
    
Ah, completely missed the symlink thing. Nice one! – slhck Nov 16 '12 at 8:06
    
Yes, that's very OS X specific. Another example is /var, it is symlinked to private/var. – jaume Nov 16 '12 at 8:19

Unfortunately, easiest way for me currently is to switch from /bin/bash to bin/zsh (Terminal Preferences - Shell open with).

Its a pity though, that I cannot easily achieve needed behavior with bash "from the box".

And I still have to export my aliases and so on...

share|improve this answer

You must log in to answer this question.

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