|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "rmate" |
| 4 | +description: "Remote TextMate 2 implemented as shell script" |
| 5 | +category: utility |
| 6 | +tags: [osx, utility, utils] |
| 7 | +--- |
| 8 | + |
| 9 | +## Description |
| 10 | + |
| 11 | +This shell script needs to be installed on a remote machine to allow editing files |
| 12 | +using TextMate 2 (TM2). TM2 needs to be configured accordingly to accept either local |
| 13 | +or remote clients. |
| 14 | + |
| 15 | +### Local clients |
| 16 | + |
| 17 | +It's a good idea to allow access to TM2 only for local clients. In this case it's required |
| 18 | +to open a SSH connection to the remote system and specify a remote tunnel in addition: |
| 19 | + |
| 20 | + ssh -R 52698:localhost:52698 [email protected] |
| 21 | + |
| 22 | +After log-in on the remote system a file can be edited by just executing |
| 23 | + |
| 24 | + rmate test.txt |
| 25 | + |
| 26 | +### Remote clients |
| 27 | + |
| 28 | +On some machines, where port forwarding is not possible, for example due to a missing ssh |
| 29 | +daemon, it's required to set TM2 to allow access for "remote clients". After log-in on the |
| 30 | +remote machine a file can be edited by executing |
| 31 | + |
| 32 | + rmate -H textmate-host test.txt |
| 33 | + |
| 34 | +## Requirements |
| 35 | + |
| 36 | +A bash with compiled support for "/dev/tcp" is required. |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +Edit specified file |
| 41 | + |
| 42 | + $ ./rmate [arguments] [--] file-path |
| 43 | + |
| 44 | +Read text from stdin |
| 45 | + |
| 46 | + $ echo "hello TextMate" | ./rmate [arguments] - |
| 47 | + |
| 48 | +### Arguments |
| 49 | + |
| 50 | + -H, --host HOST Connect to HOST. Use 'auto' to detect the host from SSH. |
| 51 | + -p, --port PORT Port number to use for connection. |
| 52 | + -w, --[no-]wait Wait for file to be closed by TextMate. |
| 53 | + -l, --line LINE Place caret on line number after loading file. |
| 54 | + +N Alias for --line, if N is a number (eg.: +5). |
| 55 | + -m, --name NAME The display name shown in TextMate. |
| 56 | + -t, --type TYPE Treat file as having specified type. |
| 57 | + -n, --new Open in a new window (Sublime Text). |
| 58 | + -f, --force Open even if file is not writable. |
| 59 | + -v, --verbose Verbose logging messages. |
| 60 | + -h, --help Display this usage information. |
| 61 | + --version Show version and exit. |
| 62 | + |
| 63 | + |
| 64 | +### Default parameter configuration |
| 65 | + |
| 66 | +Some default parameters (_host_ and _port_) can be configured by defining them |
| 67 | +as the environment variables `RMATE_HOST` and `RMATE_PORT` or by putting them |
| 68 | +in a configuration file. The configuration files loaded are `/etc/rmate.rc` |
| 69 | +and `~/.rmate.rc`, e.g.: |
| 70 | + |
| 71 | + host: auto # prefer host from SSH_CONNECTION over localhost |
| 72 | + port: 52698 |
| 73 | + |
| 74 | +Alternative notation for configuration file is: |
| 75 | + |
| 76 | + host=auto |
| 77 | + port=52698 |
| 78 | + |
| 79 | +The precedence for setting the configuration is (higher precedence counts): |
| 80 | + |
| 81 | +1. default (localhost, 52698) |
| 82 | +2. /etc/rmate.rc |
| 83 | +3. ~/.rmate/rmate.rc |
| 84 | +4. ~/.rmate.rc |
| 85 | +5. environment variables (RMATE\_HOST, RMATE\_PORT) |
| 86 | + |
| 87 | +## Links |
| 88 | + |
| 89 | +* [Source Code (GitHub)][https://github.com/aurora/rmate] |
| 90 | +* [Author: Harald Lapp](https://github.com/aurora) |
| 91 | + |
| 92 | + |
0 commit comments