My current use pattern of emacs results in my having several shell-mode buffers open, each running an ssh session. I am running into an issue with this, though - when I try to tab-complete file names and other things in my remote session, the shell attempts to use completions available on the local machine instead of on the remote machine.
For example, if the file ~/foobar
exists on the local machine and ~/frob
exists on the remote machine, typing in ~/f
and pressing tab results in ~/foobar
instead of completing correctly. If I use ssh outside of emacs and try the same thing, I get the correct completion of ~/frob
instead.
How can I get tab-completion to complete the way it does in normal ssh sessions ?
Later note: M-x cd RET /ssh:host.example.com:/path/to/me also seems to nudge it into being able to gracefully deal with tab completion.
7.7 How do I use a shell in Emacs? You can start an interactive shell in Emacs by typing M-x shell . By default, this will start the standard Windows shell cmd.exe . Emacs uses the SHELL environment variable to determine which program to use as the shell.
Bash completion is a bash function that allows you to auto complete commands or arguments by typing partially commands or arguments, then pressing the [Tab] key. This will help you when writing the bash command in terminal.
Shell mode is a derivative of Comint mode, a general-purpose mode for communicating with interactive subprocesses. Most of the features of Shell mode actually come from Comint mode, as you can see from the command names listed above.
Emacs can't track the current directory (default-directory) when ssh-ing to other machines.
You could set default-directory to a tramp file-name like /ssh:YOURHOST:/home/dir" on your current shell-buffer manually.
I start shell-sessions on a remote machine mostly via tramp-bookmarks/shell. Tramp sets default-directory automatically. But there is a bug in directory tracking on remote files, which is fixed in trunk (unreleased).
http://comments.gmane.org/gmane.emacs.bugs/39082
Instead of running M-x shell and running ssh to the remote computer, visit a directory on the remote computer (using Tramp) and then run M-x shell in that Dired buffer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With