在本地Sublime文本或TextMate 2中从远程计算机打开和编辑文件。
rsub的Python项目详细描述
使用rsub,您可以从远程计算机打开和编辑文件(您是 通过ssh连接)在本地的Sublime Text*或TextMate 2中。无需设置共享 文件系统之类的,就一个SSH tunnel!
此脚本是原始脚本的端口 rmate。
*要让它在需要的超文本上工作 ` rsub plugin<;https://github.com/jirutka/rsub plugin>;`\
安装
rsub需要python 2.7+或3.×和模块 docopt0.4.0+。
全系统
从PYPI系统范围安装:
sudo pip install rsub
…或手动:
git clone git@github.com:jirutka/rsub-client.git cd rsub-client sudo ./setup.py install cd .. && rm -Rf rsub-client
局部
如果您没有系统的根访问权限,或者只是不想 在系统范围内安装rsub,然后您可以告诉pip或setup.py到 将rsub安装到主目录(即~/.local):
pip install --user rsub
…或手动:
git clone git@github.com:jirutka/rsub-client.git cd rsub-client ./setup.py --user install cd .. && rm -Rf rsub-client
rsub脚本应安装在~/.local/bin中。如果你想要 要从任何地方访问它,请将此目录添加到您的PATH (根据正在使用的shell选择一个):
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc # bash echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.zshrc # zsh echo 'set -x PATH $HOME/.local/bin $PATH' >> ~/.config/fish/config.fish # fish
用法
您可以使用rsub --help查看用法:
Usage: rsub [options] [-l NUM] [-m NAME] [-t TYPE] - rsub [options] [-l NUM...] [-m NAME...] [-t TYPE...] FILE... - Read from the standard input. FILE File to open (will be created if does not exist yet). -l NUM --line=NUM Place caret on line [NUM] after loading the file. -m NAME --name=NAME The display name shown in editor. -t TYPE --type=TYPE Treat file as having [TYPE] (e.g. rb, py, md). Options: -H HOST --host=HOST Connect to host. Use 'auto' to detect the host from SSH. -p PORT --port=PORT Port number to use for connection. -w --wait Wait for file(s) to be closed by the editor. -f --force Open even if the file is not writable. -v --verbose Verbose logging messages. -h --help Show this message and exit. --version Show version and exit.
可以在/etc/rsubrc和~/.rsubrc中设置默认选项(或 /etc/rmate.rc和~/.rmate.rc与原始版本兼容 格式):
host = auto # prefer host from SSH_CONNECTION over localhost port = 52698
您还可以设置RSUB_HOST和RSUB_PORT(或RMATE_HOST 以及RMATE_PORT)环境变量。
设置连接
要完成它的工作,rsub需要连接回您的计算机,以便 它可以与崇高的文本或文本伴侣交谈。你可以有多种方法 实现这一点,但最好的方法可能是使用反向ssh 隧道:
ssh -R 52698:localhost:52698 example.com
-R选项设置一个反向通道。第一个52698命名为 遥控器上的端口。它将连接到localhost:52698或 接线盒上的相同端口。端口号是 sublime text,textmate 2和rsub。为了测试,发射升华 在本地计算机上运行text或textmate 2并在上运行类似的命令 遥控器:
rsub test.md
验证一切正常后,可以随时更新ssh 设置为自动设置隧道而无需提供 始终是-R参数。
对于单个服务器,只需在 ~/.ssh/config:
Host example.com RemoteForward 52698 localhost:52698
如果要将这些设置设为所有服务器的默认设置, 使用通配符主机:
Host * RemoteForward 52698 localhost:52698
更多信息可以在this blog post中找到。
许可证
这个项目是根据MIT license授权的。