#!/bin/csh -f # On open commands below: # -n = New instance of the editor, even if another instance is already open. # :q = Quote each incoming arg in case it contains embedded spaces and such. if ($#argv == 0) then # Stopped working. Had to start using "open" # /Applications/TextEdit.app/Contents/MacOS/TextEdit $*:q open -n -a TextEdit $*:q else if (-e $1:q) then # Stopped working. Had to start using "open" # /Applications/TextEdit.app/Contents/MacOS/TextEdit $*:q open -n -a TextEdit $*:q else # Create the file if it doesn't exist, since TextEdit doesn't do so. # TODO: Should loop and create all specified files, not just first one touch $1:q # Stopped working. Had to start using "open" # /Applications/TextEdit.app/Contents/MacOS/TextEdit $*:q # -W = Wait till it exits before proceeding open -n -W -a TextEdit $*:q # Delete the file if still zero length after editing. # This is especially useful for typos in filenames, so the misspelled # file doesn't get created and left there. # TODO: Should loop and delete all specified empty files, not just # first one if (-z $1:q) rm -i -v $1:q endif endif