Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open local text application to edit remote text file using ssh?

Tags:

ssh

vps

textmate

So i am in a VPS terminal using ssh.

In normal case I could just run locally

mate <file>

and it fires up TextMate with that file.

Is it possible to use the same command and somehow open the local TextMate application but editing the remote file?

That would be good if you are working in VPS and don't want to use vim all the time.

like image 584
never_had_a_name Avatar asked Sep 13 '10 03:09

never_had_a_name


People also ask

Does vim work over SSH?

Vim/NeoVim is just an editor but it relies on scp and ssh to provide access to remote files. So whenever you can ssh into any Linux box, you can also locally edit the file, while remotely saving that file into the remote server.


2 Answers

The solution is to mount the remote system using sshfs. On OS X, sshfs can for instance be installed by using Homebrew.

The filesystem is mounted via SSH using your regular SSH credentials or key so it's very easy to do, and then you navigate it as if it's a local directory and enjoy the benefit of having access to all your local tools.

like image 170
furtive Avatar answered Sep 22 '22 02:09

furtive


You have different options:

  • mounting a remote filesystem using (Mac)Fuse (as recommended by furtive),
  • synchronize your remote directory:
    • with rsync (as recommended by eglasius),
    • with an SCM (like git or hg or others),
  • or, and this would be my preferred way, use Emacs (Aquamacs, I guess, in your case) and use the tramp mode to edit remote files.

I used to do this in a few years back for some projects, and it worked perfectly, both for LANs and WANs.

If you want to stick to TextMate, then furtive's solution is ideal.

like image 45
haylem Avatar answered Sep 24 '22 02:09

haylem