Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs remote shell

Tags:

shell

emacs

I tend to run my shell in emacs, but when I use it to ssh into another computer this breaks tab-completion. Is there a way to fix this?

like image 731
Nathaniel Flath Avatar asked Jul 15 '09 21:07

Nathaniel Flath


People also ask

How do I run a shell command 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.

What is Emacs tramp?

TRAMP is for transparently accessing remote files from within Emacs. TRAMP enables an easy, convenient, and consistent interface to remote files as if they are local files.


2 Answers

Try:

M-x cd /hostname:/current/path/in/the/shell

That should set up ange-ftp (or tramp), and then TAB completion for paths should work properly for that shell - until you log into a different machine.

You could set up a comint process filter to recognize when you type ssh to do that for you automatically, but that's difficult to get right as it should revert when you exit the ssh session, but not be tricked by other uses of exit.

For an automated solution, I'd suggest augmenting the approach I personally use to keep Emacs synchronized with the current working directory of the shell buffer. Just add an an extra bit of information with the hostname, and use that to set the hostname and path like shown above.

like image 191
Trey Jackson Avatar answered Oct 08 '22 02:10

Trey Jackson


in another thread, someone mentioned eshell which I've never used but I tried it with SSH and all sorts of nice integration is happening. Time to learn eshell.

like image 31
r giar Avatar answered Oct 08 '22 04:10

r giar