I'm trying to use Sublime Text 2 as an editor when I SSH in to my work server, and I'm stumped. I found this http://urbangiraffe.com/2011/08/13/remote-editing-with-sublime-text-2/ (among many other posts) that looks like it might help, but I don't follow it exactly, particularly with what values I should put in for the remote variable in line 5. I set "/Users/path/to/local/copy" to my local root directory, but I don't know if that's right or if there's more to do. Any thoughts? I'm on OSX10.8


当前回答

Lsyncd似乎是SSHFS方法的一个不错的替代方案。如果你使用“-delay 0”,它可以实时工作。

其他回答

一个对我来说非常有用的解决方案——在Mac上进行本地编辑,然后让文件自动同步到远程机器上

Make sure you have passwordless login to the remote machine. If not, follow these steps http://osxdaily.com/2012/05/25/how-to-set-up-a-password-less-ssh-login/ create a file in ~/Library/LaunchAgents/filesynchronizer.plist, with the following content: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>filesynchronizer</string> <key>ProgramArguments</key> <array> <string>/usr/bin/rsync</string> <string>-avz</string> <string>/Users/USERNAME/SyncDirectory</string> <string>USERNAME@REMOTEMACHINE:~</string> </array> <key>WatchPaths</key> <array> <string>/Users/USERNAME/SyncDirectory</string> </array> </dict> </plist> In a terminal window run launchctl load ~/Library/LaunchAgents/filesynchronizer.plist That's it. Any changes to any files in ~/SyncDirectory will be synchronized to ~/SyncDirectory on the remote machine. Local changes will override any remote changes.

这将创建一个监视SyncDirectory的launchd作业,当有任何更改时,将运行rsync将该目录同步到远程计算机。

有三种方法:

Use SFTP plugin (commercial) http://wbond.net/sublime_packages/sftp - I personally recommend this, as after settings public SSH keys with passphrase it is safe, easy and worth every penny http://opensourcehacker.com/2012/10/24/ssh-key-and-passwordless-login-basics-for-developers/ Mount the remote as local file system using osxfuse and sshfs as mentioned in the comments. This might be little difficult, depending on OSX version and your skills with UNIX file systems. Hack together something like rmate which does file editing over remote tunneling using some kind of a local daemon (very difficult, cumbersome, but sudo compatible) http://blog.macromates.com/2011/mate-and-rmate/

此外,理论上,你可以在远程服务器上安装X11,并通过VNC或X11转发在那里运行Sublime,但这将非常缓慢。

您可以使用rsub,它的灵感来自TextMate的rate。从描述来看:

Rsub是Sublime Text 2的TextMate 2的“rate”特性的实现,允许使用SSH端口转发/隧道在远程服务器上编辑文件。

这里有一个关于如何正确设置它的好教程:(断开链接)http://log.liminastudio.com/writing/tutorials/sublime-tunnel-of-love-how-to-edit-remote-files-with-sublime-text-via-an-ssh-tunnel

Lsyncd似乎是SSHFS方法的一个不错的替代方案。如果你使用“-delay 0”,它可以实时工作。

作为@ubik回答的后续,以下是让“subl”命令在远程服务器上工作的三个简单(一次性)步骤:

使用Sublime包管理器在Sublime Text中安装rsub包 [Local]执行以下Bash命令(这将建立一个SSH隧道,这是rsub的秘密武器): printf "Host *\n RemoteForward 52698 127.0.0.1:52698" >> ~/.ssh/config 在远程服务器上执行以下Bash命令(这将安装subl shell命令): sudo wget -O /usr/local/bin/subl https://raw.github.com/aurora/rmate/master/rmate Sudo chmod +x /usr/local/bin/subl

瞧!你现在在SSH上使用Sublime Text。

你可以从服务器上用subl ~/test.txt打开Sublime Text中的示例文件