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


当前回答

使用FileZilla

这适用于Mac和Windows用户(我在Mac上使用)。多年来,我使用了列出的几个答案,发现FileZilla很适合我在有SSH访问权限的远程主机上编辑文件时的需求。它的设置也很快。

我配置一个新的服务器连接 连接到服务器 右键点击我想编辑的文件,选择查看/编辑。

这会打开我的默认编辑器(Sublime),但它可以与任何编辑器一起工作 已安装的编辑器。

一旦我保存了文件,Filezilla会自动提示我是否要“将该文件上传到服务器”,我点击“是”,然后它就更新了。

其他回答

你可以试试我一直在研究的一种叫做“xeno”的东西。它将允许您通过SSH连接打开Sublime文本(或任何本地编辑器)中的文件/文件夹,并自动将更改同步到远程机器。它应该可以在几乎所有的POSIX系统上工作(我自己使用它从OS X连接到Linux机器并在Sublime Text中编辑文件)。它是免费的,开源的。我想要一些反馈。

For more information: it's basically a Git/SSH mashup written in Python that allows you to edit files and folders on a remote machine in a local editor. You don't have to configure kernel modules, you don't need to have a persistent connection, it's all automatic, and it won't interfere with existing source control because it uses an out-of-worktree Git repository. Also, because it's built on Git, it's extremely fast and supports automatic merging of files that might be changing on both ends, unlike SSHFS/SFTP which will just clobber any files with older timestamps.

使用FileZilla

这适用于Mac和Windows用户(我在Mac上使用)。多年来,我使用了列出的几个答案,发现FileZilla很适合我在有SSH访问权限的远程主机上编辑文件时的需求。它的设置也很快。

我配置一个新的服务器连接 连接到服务器 右键点击我想编辑的文件,选择查看/编辑。

这会打开我的默认编辑器(Sublime),但它可以与任何编辑器一起工作 已安装的编辑器。

一旦我保存了文件,Filezilla会自动提示我是否要“将该文件上传到服务器”,我点击“是”,然后它就更新了。

有三种方法:

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,但这将非常缓慢。

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将该目录同步到远程计算机。