tags:

views:

1671

answers:

4

Hi emacs users, I wonder if anyone out there uses ssh through the emacs shell. I am able to connect with the remote machine but I cannot open files to view/edit with emacs using 'emacs filename' as the 'Terminal type "dumb" is not powerful enough to run emacs' (normally emacs would open within the console when connecting through the terminal).

Is this a bad idea to try to use emacs in such a way, or is this possible with a few fixes? Thanks much!

+4  A: 

You could use ssh x forwarding to run a remote emacs and display it on the local computer.
I use Xming X Server when I'm on Windows

You could mount the remote filesystem with ssh and open the locally as normally.
For this I use ExpanDrive (commercial app) when on Windows

You could use emacs Ange ftp over ssh it can open remote files over ftp and ssh.
I use this with cygwin when on Windows

Nifle
thank you! -very helpful
Stephen
+3  A: 

A couple of ideas

  • Source the .bashrc explicitly via . ~/.bashrc and/or rearrange your bash init files and ~/.profile so that this gets loaded inside the emacs shell; then running ssh inside the Emacs shell works just fine
  • Use the emacs-specific Tramp mode to access remote files via ssh inside your local Emacs -- this is useful if you just need to update/touch/edit a remote file so you would not need to open a remote emacs inside the ssh session started from inside your local emacs.
Dirk Eddelbuettel
I'll have to check out this Tramp mode, sounds great. Thanks!
Stephen
Yes -- the other questioner beat me to the first reply by a minute or two but tramp is what you're after if you just want to quickly edit a file or two other host. It simple copies it to your machine and sends updates versions back via scp -- without you having to do it explicitly. That can be much more leightweight than export an X11 session (which he rightly pointed out as another option).Also, tramp is very much the follow-up to the older ange ftp he mentioned.
Dirk Eddelbuettel
Yes, I noticed that tramp supercedes ange ftp (according to other threads). And my X11 connections seem to be terribly slow so tramp is definitely better for my situation. Thank you.
Stephen
My pleasure. If you think that's the right answer I guess you could also accept it as the official answer :-)
Dirk Eddelbuettel
+5  A: 

Emacs has term-mode which is full blown terminal emulator you can run emacs in emacs. Anything you run on terminal will run in term-mode

Also emacs has tramp mode which can open files through ssh.


/scp:user@ipOrHost#port:/

it will transfer files back and forth. you just edit them as you would edit local files.

No need for x11 forwarding or other shenanigans.

Hamza Yerlikaya
Thanks - there seem to be many options: shell, eshell, and term... which one do you prefer? I've googled a bit and it seemed that 'shell' was the most widely used...
Stephen
shell and eshell despite their names are not real shells. they just read and write to a process. but term on the other hand is an terminal emulator just like terminal on osx or xterm on linux. you can even run ncurses stuff in it which you can not do in shell. use term if you want to live in emacs and use shell if you want to run quick commands and still use a terminal ( xterm etc..)
Hamza Yerlikaya
Ah, yes - there seems to be some griping about term not having the documentation that shell and eshell does but it does appear to handle my ssh session better than shell... but emacs within emacs? "emacs: Terminal type eterm-color is not defined." says something about having to change the TERM variable, but if I read up on it more I suppose that it can be done? Scary!
Stephen
+3  A: 

It may not be obvious on first sight, but eshell, the shell that is implemented in Emacs Lisp works fine with tramp:

Welcome to the Emacs shell

~ $ uname -a
Linux local-machine 2.6.30-1-686 #1 SMP Thu Jul 30 14:45:30 UTC 2009 i686 GNU/Linux
~ $ cd /ssh:user@remote-machine:~
/ssh:user@remote-machine:/home/user $ uname -a
Linux remote-machine 2.6.18-6-686 #1 SMP Thu Aug 20 21:56:59 UTC 2009 i686 GNU/Linux
/ssh:user@remote-machine:/home/user $
hillu
Wow, that looks pretty awesome. Emacs has two too many shell options!
Stephen