Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Background context: I want the ssh command on the OS X terminal to tab-complete hostnames I use frequently. On Ubuntu, ssh seems smart enough to be able to tab-complete any hostname I have in my ~/.ssh/config file. But OS X does not seem to have this behavior, so I'm trying to manually force tab-completion for some hosts I use very frequently.

If I open up a terminal and run this:

$ complete -W ssh

Then typing ssh f<tab> will complete into ssh

Question: when I put such a command in my ~/.bash_profile, it no longer works. Why?

I'm sure the ~/.bash_profile is being executed, as I have other things in there (prompt configs, etc) which are taking effect in my terminal session.

Shouldn't putting things in my ~/.bash_profile be the equivalent of automatically executing those commands in the terminal on session startup? It's as if the complete command runs inside a context that's lost, while other things persist (such as my PS1 prompt setting.)

Thanks for any insight here, bash experts!


Using complete to list my configuration showed me my mistake. I'm using multiple statements, ie:

complete -W ssh; complete -W ssh

And only the last one takes effect (each one replaces the one before it). So, I need to put them all in one command, ie:

complete -W 'foo bar' ssh

So this question is not about ~/.bash_profile, it's about understanding the right way to use "complete"

share|improve this question
up vote 0 down vote accepted

What happens if you try:

complete | grep ssh

does an entry show up?

I would recommend installing the bash-completion package.

share|improve this answer
Thanks for the pointer. Using complete to list my configuration showed me my mistake. I updated my question and closed this out. Thanks! – Yetanotherjosh Jun 30 '10 at 16:10

Your Answer


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.