9

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?

Falmarri
  • 13,047

1 Answers1

8

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)
  • 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 04 '10 at 17:33
  • @Falmarri updated answer with the more info; does this answer your further questions? – Riccardo Murri Oct 04 '10 at 18:00
  • Ah that makes sense, yeah – Falmarri Oct 04 '10 at 18:58