TextMate 2 adds a nice feature, where it is possible to edit files on a remote serverusing a helper script. The original helper script provided with TM2 is implemented inruby. Here is my attempt to replace this ruby script with a shell script, because insome cases a ruby installation might just be too much overhead for just editing remotefiles.
This script can be used with some other editors (e.g. Sublime Text) via available plug-ins.
The shell script needs to be copied to the server, you want to remote edit files, on.After that, you should set-up your editor to communicate with rmate.
sudo wget -O /usr/local/bin/rmate https://raw.githubusercontent.com/aurora/rmate/master/rmate
sudo chmod a+x /usr/local/bin/rmate
or with bpkg
bpkg install aurora/rmate
Open your TM2 preferences and enable "Allow rmate connections" setting inthe "Terminal" settings and adjust the setting "Access for" according to your needs:
It's a good idea to allow access only for local clients. In this case you need to opena SSH connection to the system you want to edit a file on and specify a remote tunnel inaddition:
ssh -R 52698:localhost:52698 user@example.com
Or put the following lines in your local ~/.ssh/config
:
Host example.com
RemoteForward 52698 127.0.0.1:52698
If you are logged in on the remote system, you can now just execute
rmate test.txt
On some machines, where port forwarding is not possible, for example due to a missing sshdaemon, you can allow access for "remote clients". Just ssh or telnet to the remote machineand execute:
rmate -H textmate-host test.txt
To use rmate with Sublime Text, you need to install a plug-in, e.g.rsubor RemoteSubl.
You can install plug-ins via Package Control.Install Package Control,press Cmd + Shift + P
for Mac and Ctrl + Shift + P
for Linux/Windows,select Package Control: Install Package
,and, finally, select rsub
for rsub or RemoteSubl
for RemoteSubl.
Also, you can install plug-ins manually.
git clone https://github.com/henrikpersson/rsub ~/.config/sublime-text-3/Packages/rsub
git clone https://github.com/randy3k/RemoteSubl ~/.config/sublime-text-3/Packages/RemoteSubl
git clone https://github.com/henrikpersson/rsub %APPDATA%/Sublime\ Text\ 3/Packages/rsub
git clone https://github.com/randy3k/RemoteSubl %APPDATA%/Sublime\ Text\ 3/Packages/RemoteSubl
git clone https://github.com/henrikpersson/rsub ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/rsub
git clone https://github.com/randy3k/RemoteSubl ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/RemoteSubl
Then do the same things as described in Local clients part of this document.
To use rmate with VS Code, you need to install an extension, e.g.Remote VSCode
//-------- Remote VSCode configuration --------
// Port number to use for connection.
"remote.port": 52698
// Launch the server on start up.
"remote.onstartup": true
// Address to listen on.
"remote.host": "127.0.0.1"
// If set to true, error for remote.port already in use won't be shown anymore.
"remote.dontShowPortAlreadyInUseError": false
Then do the same things as described in Local clients part of this document.
Example session: Editing html file located on an SGI o2: https://github.com/aurora/rmate/wiki/Screens
A bash with compiled support for /dev/tcp
is required. This is not the case on someolder linux distributions, like Ubuntu 9.x.
Edit specified file
$ ./rmate [arguments] [--] file-path
Read text from stdin
$ echo "hello TextMate" | ./rmate [arguments] -
-H, --host HOST Connect to HOST. Use 'auto' to detect the host from SSH.
-p, --port PORT Port number to use for connection.
-w, --[no-]wait Wait for file to be closed by TextMate.
-l, --line LINE Place caret on line number after loading file.
+N Alias for --line, if N is a number (eg.: +5).
-m, --name NAME The display name shown in TextMate.
-t, --type TYPE Treat file as having specified type.
-n, --new Open in a new window (Sublime Text).
-f, --force Open even if file is not writable.
-v, --verbose Verbose logging messages.
-h, --help Display this usage information.
--version Show version and exit.
Some default parameters (host
and port
) can be configured by defining themas the environment variables RMATE_HOST
and RMATE_PORT
or by putting themin a configuration file. The configuration files loaded are /etc/rmate.rc
and ~/.rmate.rc
, e.g.:
host: auto # prefer host from SSH_CONNECTION over localhost
port: 52698
Alternative notation for configuration file is:
host=auto
port=52698
The precedence for setting the configuration is (higher precedence counts):
localhost
, 52698
)/etc/rmate.rc
~/.rmate/rmate.rc
~/.rmate.rc
RMATE\_HOST
, RMATE\_PORT
)Use with caution. This software may contain serious bugs. I can not be made responsible forany damage the software may cause to your system or files.
rmate
Copyright (C) 2011-present by Harald Lapp harald@octris.org
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
建议使用Remote Development.拥有更好的体验。 当然也写了新的教程。https://blog.csdn.net/KnYoboy/article/details/105202229 Rmate Rmate,一个使用户可以在vscode中编辑服务器上的文件的工具(编辑完成保存后自动同步到服务器端)。用过就知道有多好用~ 服务器端 安装Rmate pip install rmate 开启
textmate 2开源的第二天就compile了一个,除了工程,exclude文件这里有点不爽。其它都非常好用,对中文支持非常好,看起来也比textmate 1漂亮多了。 有一个功能超强大是rmate,把rmate scp到服务器上。 再把路由器的端口转发打开,52698. 在服务器 rmate test.txt 在你本地的textmate 2就会弹出test.txt,就可以像
虽然公司电脑win可以通过Xshell通过SSH远程连接家中内网linux服务器了,但是只能用vim编辑文件有点不爽。 于是上网查询,windows下使用vscode远程编辑服务器文件的办法。参照博文网址:https://blog.csdn.net/yy_diego/article/details/82715276 内容如下: 首先,在本地用SSH登录到的服务器上去(默认已经把ssh都配置好了),
问题描述 $ ssh -R 52698:localhost:52698 server-name@server-ip -p server-port $ rmate filename $ (<filename> does not be opened, nothing responses) $ ... 解决方案 将ssh命令中用于描述本地主机的locaLhost替换为127.0.0.1 拓展 Remo