Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # The script will connect back to Sublime Text so you should setup
- # an ssh tunnel: ssh -R 52698:localhost:52698 user@example.org
- # Required: RemoteSubl package installed in Sublime Text
- if [ $# -eq 0 ]
- then
- echo "no remote suplied" >/dev/stderr
- exit 1
- fi
- # Check if we can access the remote host
- ssh $@ "exit" || exit 1
- clear
- echo "Installing rmate on remote..."
- if command -v wget >/dev/null 2>&1
- then
- wget -qO- https://raw.githubusercontent.com/aurora/rmate/master/rmate | ssh $@ "cat > ~/rmate"
- else
- curl -s https://raw.githubusercontent.com/aurora/rmate/master/rmate | ssh $@ "cat > ~/rmate"
- fi
- if ! ssh $@ "sudo mv ~/rmate /usr/local/bin && sudo chmod +x /usr/local/bin/rmate || (rm ~/rmate; exit 1)" >/dev/null 2>&1
- then
- echo "Sorry, installing rmate failed."
- exit 1
- fi
- PROFILE=$(ssh $@ "ls .*profile")
- if [ $(ssh $@ "grep -c 'alias subl' $PROFILE") -eq 0 ]
- then
- echo "Creating aliases ..."
- ssh $@ "echo >> $PROFILE"
- ssh $@ "echo \"alias rmate='/usr/local/bin/rmate' \" >> $PROFILE"
- ssh $@ "echo \"alias rsubl='rmate' \" >> $PROFILE"
- ssh $@ "echo \"alias subl='rmate' \" >> $PROFILE"
- ssh $@ "echo \"alias sudo='sudo '\" >> $PROFILE"
- fi
- if [ $? -eq 0 ]
- then
- echo
- echo "Setup an ssh tunnel with:"
- echo
- echo " ssh -R 52698:localhost:52698 $@"
- echo
- echo "Done!"
- exit 0
- else
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement