Skip to content

Instantly share code, notes, and snippets.

@jpscharf
Forked from leon/ssh-copy-rmate
Created August 22, 2013 14:29
Show Gist options
  • Save jpscharf/6307930 to your computer and use it in GitHub Desktop.
Save jpscharf/6307930 to your computer and use it in GitHub Desktop.
#!/bin/sh -r
#
# Usage: ssh-copy-rmate [--bash] [user@]machine
#
# Shell script to install rmate on the remove server so we can open shell scripts locally.
# Author: Leon Radley (http://github.com/leon)
URL="https://raw.github.com/textmate/rmate/master/bin/rmate"
if [ "$#" -gt 1 ] || [ "$1" = "-b" ] || [ "$1" = "--bash" ]; then
shift
URL="https://raw.github.com/aurora/rmate/master/rmate"
fi
if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
cat <<EOF
Usage: $0 [--bash] [user@]machine
# Install TextMate2 and enable rmate in the preferences
http://blog.macromates.com/2011/mate-and-rmate/
# Setup ssh for easy access
edit ~/.ssh/config
# The automatic forwarding
RemoteForward 52698 localhost:52698
# Standard user, so you can do ssh servername instead of root@servername
User root
# Custom aliases
Host myalias
HostName myserver.mydomain.com
User myuser
EOF
exit 1
fi
wget --quiet -O - "${URL}" | ssh ${1%:} 'umask 077; test -d /usr/local/bin || mkdir -p /usr/local/bin; cat > /usr/local/bin/rmate; chmod a+rx /usr/local/bin/rmate' || exit 1
cat <<EOF
Installation complete!
For more information run $0 --help
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment