Editing remote files over SSH, using TextMate?

MacosTextmate

Macos Problem Overview


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?

Macos Solutions


Solution 1 - Macos

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

Solution 2 - Macos

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.

Solution 3 - Macos

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.

Solution 4 - Macos

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

Solution 5 - Macos

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/.

Solution 6 - Macos

Try one of these methods.

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

also have a look at:

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

Solution 7 - Macos

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.

Solution 8 - Macos

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?

Solution 9 - Macos

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.

Solution 10 - Macos

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.

Solution 11 - Macos

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.

Solution 12 - Macos

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.

Solution 13 - Macos

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

Solution 14 - Macos

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

Solution 15 - Macos

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).

Solution 16 - Macos

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,

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionZack BurtView Question on Stackoverflow
Solution 1 - MacosKim SharmaView Answer on Stackoverflow
Solution 2 - MacosScott GieseView Answer on Stackoverflow
Solution 3 - MacosAhmed JolaniView Answer on Stackoverflow
Solution 4 - MacosRoger GilbratView Answer on Stackoverflow
Solution 5 - MacosascotanView Answer on Stackoverflow
Solution 6 - MacosEddy PronkView Answer on Stackoverflow
Solution 7 - MacosLie RyanView Answer on Stackoverflow
Solution 8 - MacosromainlView Answer on Stackoverflow
Solution 9 - MacosNick JenningsView Answer on Stackoverflow
Solution 10 - MacosSergei GView Answer on Stackoverflow
Solution 11 - MacosKevinView Answer on Stackoverflow
Solution 12 - MacosHerón Ordóñez GuillénView Answer on Stackoverflow
Solution 13 - MacosAkshay AgarwalView Answer on Stackoverflow
Solution 14 - MacosgiorgioView Answer on Stackoverflow
Solution 15 - MacosHaydenView Answer on Stackoverflow
Solution 16 - MacosMohammed SheriffView Answer on Stackoverflow