/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# 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 }