[TxMt] Default "Save As..." filename...
Hans-Joerg Bibiko
bibiko at eva.mpg.de
Fri Oct 26 13:34:08 UTC 2007
> Write a command:
>
> Input: Selected Text or Nothing
>
> Command:
> FILENAME="$TM_SELECTED_TEXT"
> EXT=$("$TMTOOLS" get suggestedExtensionForDocument)
> filename="$(CocoaDialog filesave --with-directory `dirname
> "$TM_FILEPATH"` --with-file "$FILENAME.$EXT" )"
> if [ -n "$filename" ]; then
> echo "{name=\""$filename"\";overwriteMode;}" |"$TMTOOLS" do
> saveWithFilenameAndReopen -
> fi
>
> Output: Show a Tool Tip
>
Or if you want to bind that command to APPLE+SHIFT+S you can try this
as command:
FILENAME="$TM_SELECTED_TEXT"
if [ -z "$TM_SELECTED_TEXT" ]; then
"$TMTOOLS" show saveAsPanel
exit_show_tool_tip
fi
FMF=$("$TMTOOLS" get frontMostDocument)
if [ "${FMF:0:8}" == "untitled" ]; then
EXT=$("$TMTOOLS" get suggestedExtensionForDocument)
filename="$(CocoaDialog filesave --with-directory `dirname
"$TM_FILEPATH"` --with-file "$FILENAME.$EXT" )"
if [ -n "$filename" ]; then
echo "{name=\""$filename"\";overwriteMode;}" |"$TMTOOLS" do
saveWithFilenameAndReopen -
fi
else
"$TMTOOLS" show saveAsPanel
exit_show_tool_tip
fi
--Hans
More information about the textmate
mailing list