Zack Burt
Zack Burt

Reputation: 8455

Editing remote files over SSH, using TextMate?

I LOVE using TextMate on my MacBook. It's great.

Unfortunately, I want to edit some files directly on my dev server, since it's difficult to recreate the environment locally. I'm using Git, so one alternative is to just edit locally, git commit, git push, and then git merge, but that's kind of complicated every time I want to make a simple change.

I'd rather just ... use another solution. One thing I tried is mounting a hard drive via MacFusion, and then loading that in an editor. But that's so freaking laggy/slow!

Has anyone cooked up a better solution?

Upvotes: 54

Views: 41048

Answers (16)

Mohammed Sheriff
Mohammed Sheriff

Reputation: 93

For those remote machines not having ruby or if bash not compiled with /dev/tcp, but has python, this works: https://github.com/scriptmaster/rmate-python

If you have pip: pip install rmate

or simply:

wget https://raw.githubusercontent.com/scriptmaster/rmate-python/master/bin/rmate
chmod +x ./rmate
mv ./rmate /usr/local/bin/rmate

then rmate /path/to/file

especially if you are in a containerd-os with restrictions (with only python and docker) such as kubernetes-vm or gce-vm

you don't need vs-code-server, atom-editor,

Upvotes: 0

Hayden
Hayden

Reputation: 115

rmate might be another choice. On server side, you type rmate /path/to/file. The file will be transferred to local machine, where you use some editor like Sublime Text or VS Code (TexMate may also work). To use it, one needs to install both server and client.

For server side, there are several ones in various languages. Choose one you like. Here is the Github repo.

On local machine, as far as I know, VS Code and Sublime Text have their extensions to receive files. For VS Code, refer to here. For Sublime Text, refer to here.

On the other hand, Microsoft just announced an official remote editing extension for VS Code (not released yet).

Upvotes: 0

Kim Sharma
Kim Sharma

Reputation: 526

OK - here is the one that works on Mountain Lion.

  1. Go to http://osxfuse.github.com/
  2. Install FUSE for OS X
  3. Install SSHFS for OS X
  4. Then the following commands on your terminal:

mkdir /Volumes/SSHFS

/usr/local/bin/sshfs username@host:/path/to/dir /Volumes/SSHFS

Done.

I would also recommend using the ReMate plugin as pointed out by another user to prevent TextMate from beach-balling every time you refocus it. Link:

ReMate http://ciaranwal.sh/remate

Upvotes: 40

Sergei G
Sergei G

Reputation: 1700

Most of the proposed solutions are centered around sshfs in one form or another. I have tried these solutions, but I found that reliability of filesystem is not always as good as desired.

There is tool called rmate, which allows editing of remote files in text mate.

Use command from ssh session to edit file on the server:

rmate file_name

The readme on github provides easy to follow instructions on how to set it up.

Upvotes: 1

giorgio
giorgio

Reputation: 2195

You need rmate it works fine to edit files on your server via ssh using TextMate on you local machine. Github link here

Upvotes: 0

Akshay Agarwal
Akshay Agarwal

Reputation: 2039

If you do use an IDE, you could just set up an SSH tunnel to your dev server and edit your files from the comfort of your favourite IDE. Saving the files locally would automatically then push the files on the dev server as well

P.S: I am NOT endorsing the use of IDE

Upvotes: 0

Ahmed Jolani
Ahmed Jolani

Reputation: 3072

The best thing would be using TextMate's rmate script, follow the link and you'll find the instructions bellow, I recommend it since it will make your life easier and handle all the Nitty-Gritty.

Upvotes: 10

Use Fuse for OS X http://osxfuse.github.com and the companion package, SSHFS (same URL) and install them. I installed the MacFUSE compatibility libraries from there too, just for good measure.

Then, install http://macfusionapp.org and follow the instructions located here ( https://github.com/osxfuse/osxfuse/wiki/SSHFS ) to configure macfusion to use the newer libraries.

I had trouble getting authenticated with password, so I set up ssh key authentication and used macfusion without password. Works like a charm.

Upvotes: 0

ascotan
ascotan

Reputation: 1684

The correct answer is to use sshfs and make sure "Perform atomic saves" is checked in the Textmate preferences window. The easiest way to setup sshfs is to use Macfusion. http://macfusionapp.org/.

Upvotes: 3

Roger Gilbrat
Roger Gilbrat

Reputation: 3835

I use the free version of TextWrangler for just this and it works great. I can load and save files over sftp.

Upvotes: 6

Nick Jennings
Nick Jennings

Reputation: 4044

I know this question already has several answers, and it's been a while, but I wanted to also point out DokanSSHFS - This will use SSH to make a local drive of the directory location on the server that you choose. Then you can use your editor of choice to edit the files as if they were on a local disk.

Upvotes: 1

romainl
romainl

Reputation: 196596

If you are not able — for whatever reason — to replicate your environment locally and still want to use TextMate, the FTP client+TextMate combo is the best solution I can think of. MacFusion and all the other similar solutions are neat on the paper but awfully slow.

If you feel adventurous and confident enough to drop the TextMate requirement, SSH+Vim in the terminal works amazingly well.

Are you positive you can't replicate at all your remote environment?

Upvotes: 1

Kevin
Kevin

Reputation: 4287

MacFusion is pretty sweet for free - basically ssh-mounting of directories. http://macfusionapp.org/

Transmit 4 has a similar feature, tho it costs $$.

Try http://ciaranwal.sh/remate/ if it seems slow, as that will disable textmate from refreshing the file list so often.

Upvotes: 0

Scott Giese
Scott Giese

Reputation: 261

I use Fetch and TextMate for just such tasks. Fetch can be set to use TextMate as an external editor and can even automatically open files in TextMate by double clicking.

Saving the window in TextMate automatically pushes the file back to the server. Of course you would have to commit the changes on the server at a later time.

I'm sure most Mac FTP clients could do the same.

Upvotes: 11

Lie Ryan
Lie Ryan

Reputation: 64855

You don't need to push every time you make simple changes; git is a distributed version control system, you commit to your local repository for the small changes. You should only push to the remote repository once you finished working on a feature/bug (or for really huge feature, a complete subfeature). Well, that's assuming you can recreate the environment; which apparently you can't.

A decent text editor can have integration with your favorite control version system; if you cannot configure your editor to commit and push from inside your editor, get a decent editor.

An even better editor can be set to save, commit, push, compile, and run your program all in one click or keypress.

Upvotes: 1

Eddy Pronk
Eddy Pronk

Reputation: 6695

Try one of these methods.

see: http://wiki.macromates.com/Main/FAQ#projects

also have a look at:

http://www.gnu.org/software/tramp/

Upvotes: 1

Related Questions