• Stars
    star
    884
  • Rank 51,180 (Top 2 %)
  • Language
    Shell
  • License
    GNU General Publi...
  • Created over 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Remote TextMate 2 implemented as shell script

rmate

Description

TextMate 2 adds a nice feature, where it is possible to edit files on a remote server using a helper script. The original helper script provided with TM2 is implemented in ruby. Here is my attempt to replace this ruby script with a shell script, because in some cases a ruby installation might just be too much overhead for just editing remote files.

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.

Quick install

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

Set-up editor

TextMate 2

Open your TM2 preferences and enable "Allow rmate connections" setting in the "Terminal" settings and adjust the setting "Access for" according to your needs:

TM2_terminal_preferences

Local clients

It's a good idea to allow access only for local clients. In this case you need to open a SSH connection to the system you want to edit a file on and specify a remote tunnel in addition:

ssh -R 52698:localhost:52698 [email protected]

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
Remote clients

On some machines, where port forwarding is not possible, for example due to a missing ssh daemon, you can allow access for "remote clients". Just ssh or telnet to the remote machine and execute:

rmate -H textmate-host test.txt

Sublime Text

To use rmate with Sublime Text, you need to install a plug-in, e.g. rsub or 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.

  • Linux
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
  • Windows
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
  • OS X
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.

VS Code

To use rmate with VS Code, you need to install an extension, e.g. Remote VSCode

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

Example session: Editing html file located on an SGI o2: https://github.com/aurora/rmate/wiki/Screens

Requirements

A bash with compiled support for /dev/tcp is required. This is not the case on some older linux distributions, like Ubuntu 9.x.

Usage

Edit specified file

$ ./rmate [arguments] [--] file-path

Read text from stdin

$ echo "hello TextMate" | ./rmate [arguments] -

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.

Default parameter configuration

Some default parameters (host and port) can be configured by defining them as the environment variables RMATE_HOST and RMATE_PORT or by putting them in 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):

  1. default (localhost, 52698)
  2. /etc/rmate.rc
  3. ~/.rmate/rmate.rc
  4. ~/.rmate.rc
  5. environment variables (RMATE\_HOST, RMATE\_PORT)

Disclaimer

Use with caution. This software may contain serious bugs. I can not be made responsible for any damage the software may cause to your system or files.

License

rmate

Copyright (C) 2011-present by Harald Lapp [email protected]

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

More Repositories

1

iterm2-zmodem

Z-Modem integration for iTerm2
Shell
143
star
2

identicon

Shell script for creating identicons with direct SVG rendering or ImageMagick based rendering
Shell
19
star
3

asciidia

Create SVG or bitmaps from simple ASCII diagrams, EBNF notations, etc.
PHP
17
star
4

flowdesigner

Flow designer component using jquery and paper.js
JavaScript
11
star
5

rmate-nim

Remote TextMate 2 with SSL support implemented in Nim
Nim
6
star
6

iadl

Internet archive collection downloader.
Shell
6
star
7

gitsplit

Helper tool for splitting git repositories using index-filter, tries to keep history also for renamed files.
Shell
4
star
8

js99er-nw

Node Webkit frontend for the js99er TI-99/4A (ti99/4a) emulator.
JavaScript
3
star
9

pi-in-a-qube

Banana Pi in a Cobalt Qube
2
star
10

ktinit

Helper script for creating gradle-based Kotlin projects.
Shell
2
star
11

imagewarp

Perspective projection of images using openCV.
C++
2
star
12

mkinst

Tool for creating self-contained installers.
Shell
1
star
13

phpcshtml

XSLT for transforming PHP CodeSniffer XML report to HTML.
XSLT
1
star
14

TI99

Archive of my TI99 Software
1
star
15

phphttpd

Library for building self-contained scripts for serving with PHP 5.4's builtin web-server
PHP
1
star
16

phplint

Unofficial fork of phplint
C
1
star
17

vscsetup

Helper tool for setting up my Visual Studio Code environment
Shell
1
star
18

uck-setup

My helper script for creating customized liveCD from within a uck customization console.
Shell
1
star
19

set-up

my working environment
Vim Script
1
star
20

img2video

Convert images to a movie slideshow using imagemagick and ffmpeg.
Shell
1
star