Bash autocompletion in Emacs shell-mode

autocomplete, bash, emacs, shell

Solution

I know this question is three years old, but it's something that I've also been interested in solving. A Web search directed me to a piece of elisp that makes Emacs use bash for completion in shell mode. It works for me, in any case.

Check it out at https://github.com/szermatt/emacs-bash-completion .

Problem

In the GNOME Terminal, Bash does smart auto-completion. For example ``` apt-get in<TAB> ``` becomes ``` apt-get install ``` In Emacs shell-mode, this auto-completion doesn't work, even after I explicitly source `/etc/bash_completion`. The above example sticks as `in` or auto-completes with a filename in the current directory rather than a valid `apt-get` command option. Presumably, this is because Emacs is intercepting the Tab key-press. How do I enable smart auto-completion in `shell-mode`?

Original source