Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash autocompletion in Emacs shell-mode

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?

like image 804
Chris Conway Avatar asked Oct 02 '08 17:10

Chris Conway


People also ask

How do I run a shell in Emacs?

You can execute an external shell command from within Emacs using ` M-! ' ( 'shell-command' ). The output from the shell command is displayed in the minibuffer or in a separate buffer, depending on the output size.

How does autocomplete work in bash?

The programmable completion feature in Bash permits typing a partial command, then pressing the [Tab] key to auto-complete the command sequence. [1] If multiple completions are possible, then [Tab] lists them all. Let's see how it works. Tab completion also works for variables and path names.


1 Answers

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 .

like image 193
David Christiansen Avatar answered Oct 14 '22 17:10

David Christiansen