Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

It seems that bash doesn't want to autocomplete commands (what's annoying me right now is not autocompleting apt-get) when I'm logged into my machine from SSH. Is there some setting that will allow bash to autocomplete inside an ssh session?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

In short: source /etc/bash_completion should do the trick (run it in the shell within the SSH session).

Long story: in order for bash completion to work, you have to tell bash how to complete each command's arguments. This requires a long sequence of invocations of the bash built-in command complete; therefore, they are usually collected in a separate script (or several ones in /etc/bash.complete.d/*) that loads them all.

Being a regular shell script, you can always load the bash_completion in any shell startup script (~/.bash_profile, ~/.bash_login, ~/.bashrc)

Further reading:

  • section Programmable Completion in the man page bash(1)
  • help text for the complete command (run: help complete in bash)
share|improve this answer
    
Great, that works. Can you explain why you have to do this? What about an SSH session does bash not like auto-completing. Is there a way to get this to do it for every ssh session? At least for a particular user (me)? –  Falmarri Oct 4 '10 at 17:33
    
@Falmarri updated answer with the more info; does this answer your further questions? –  Riccardo Murri Oct 4 '10 at 18:00
    
Ah that makes sense, yeah –  Falmarri Oct 4 '10 at 18:58
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.