DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Open Remote File With Local Textmate

07.26.2005
| 12182 views |
  • submit to reddit
        Run this on a remote server to open the file on your local map with ssh.  Written by danp, I'm just saving this for a rainy day.

#!/bin/sh

host=`echo $SSH_CLIENT | cut -d' ' -f1`
path=`pwd | sed "s|^$HOME|/Volumes/chaos|"`
app="/Applications/TextMate.app"
file=$1

if [ ! -e $file ]; then
	echo -n "create $file? [Yn] "
	read input
	if [ -z "$input" -o "$input" = "Y" -o "$input" = "y" ]; then
		touch $file
	else
		exit
	fi
fi

ssh $host "open -a $app $path/$file; exit"