Tab Completion In Emacs shell-mode SSH Sessions

守給你的承諾、 提交于 2019-12-04 19:25:27

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/4683256/tab-completion-in-emacs-shell-mode-ssh-sessions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!