Home > emacs, Linux, Shell > eMarch 5 : Tramp

eMarch 5 : Tramp

We are all living in a modern world, the cloud is everywhere and of course also in emacs. So the closing post of this serie will talk about tramp. Tramp is so rich of features that a post won’t be enough. I’ll focus on the point I’ve used so far.

Basic use

I generally use a lot of ssh connection. Tramp allows me to naviguate through the remote directory as if they were on my local machine. The basic commands C-x D and C-x f just need a special syntax to describe the path to the file directory you want to access to.

With ssh, the syntax is similar to the scp one. Hence to access the file test.txt in your home directory “~” on remote host “rem1” , just do

C-x C-f
/ssh:rem1:~/test.txt

To access the directory “/work/you/project” on remote1 “remote1.com”, ip “127.0.0.1”

C-x d
 /ssh:remote1.com:/work/you/project
 /ssh:127.0.0.1:/work/you/project

Last, while visiting a remote directory, if you start a shell buffer with “M-x shell”, the later will be started on the remote host. If a shell buffer is already open on your localhost, M-x shell will redirect you to this buffer. The trick here is to use  C-u M-x shell to start a second buffer shell.

Some other hints

Of course the neat way to access remote host is to create a ssh config file. Anyway if your login on the remote host is different from the one you generally use, or if you are using a tunnel with a different port, you ‘ll have to modify your path.

Taking the former example, assuming now that your login is “Name” you want to connect on localhost port 9022 (We are considering an access via an ssh tunnel).

C-x d
/ssh:Name@remote1.com#9022:/work/you/project

Other useful tips and alternative can be found on the emacs wiki tramp page, like :

  • setting a default tramp user with (setq tramp-default-user “ClassicalLogin”)
  • setting a default tramp protocol (setq tramp-default-method “ssh”)
Advertisements
Categories: emacs, Linux, Shell
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: