Revision: 2241
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 22, 2007 07:31 by tictoc
Initial Code
# so we can work with relative paths cd "$TM_DIRECTORY" # construct a default name for the duplicate def_name=`perl -pe <<<"$TM_FILENAME" 's/^(.*?)(\.[^.]*)?$/$1 copy$2/'` # prompt user for a name CocoaDialog inputbox --text "$def_name" --button1 "Duplicate" --button2 "Cancel"|{ # if user selected 'Duplicate' and file doesn't exist read res; read new_name; if [[ "$res" == "1" && ! -e "$new_name" ]]; then # do the actual duplication cp -p "$TM_FILENAME" "$new_name" # force TM to refresh project drawer and open duplicate { osascript -e 'tell application "SystemEvents" to activate' \ -e 'tell application "TextMate" to activate' # open -a TextMate "$new_name"; } &>/dev/null & fi }
Initial URL
Initial Description
Initial Title
Textmate command: Duplicate file
Initial Tags
command, textmate, copy
Initial Language
Other