30
How Tos: Auto Save Copy for TextMate
2 Comments | Posted by Buddy Toups in Apple Related, Web Development
You might be migrating to TextMate from BBEdit or some other text editors. And used a featured that allowed automatic backup copies for ever file you edit and save and was looking for this feature in Textmate, honestly it doesn’t exist. I found a solution in TextMate’s Wiki that works, quiet well actually, you create a small command in the Bundle Editor:
From TextMate Wiki Main / Howtos – TextMate Wiki
The Setup: Set up a TM_BACKUP_DIR environment variable in the Advanced / Shell Variables section of the TM preferences. Set it to the directory where you’d like your backups to be saved. Use the full path (i.e., /Users/michael/Documents rather than ~/Documents).
Save: Current File
[code lang="bash"]
# Save a copy of this file to the backup directory
THEDATE=`php -r 'print date('Ymd');'`
THETIME=`php -r 'print date('His');'`
mkdir -p "$TM_BACKUP_DIR/$THEDATE"
perl -e 'while () { print $_; }' > "$TM_BACKUP_DIR/$THEDATE/$TM_FILENAME.$THEDATE.$THETIME.backup"
[/code]
Std In: Entire Document
Std Out: Discard
Activation: Key Equivalent Cmd-S
My variation of the script Michael Lehmkuhl posted in the Wiki. I change the directory creation to duplicate the full file path of the current file in the backups folder.
[code lang="bash"]# Save a copy of this file to the backup directory
THEDATE=`php -r 'print date('Ymd');'`
THETIME=`php -r 'print date('His');'`
mkdir -p "$TM_BACKUP_DIR/$TM_DIRECTORY"
perl -e 'while () { print $_; }' > "$TM_BACKUP_DIR/$TM_DIRECTORY/$THEDATE.$THETIME_$TM_FILENAME"[/code]
2 Comments for How Tos: Auto Save Copy for TextMate
Ryan | August 5, 2009 at 12:50 am
Ryan | August 5, 2009 at 12:56 am
In my above comment, the ‘b’ tags around $TM_DIRECTORY were not intended to actually make the text bold.
Ironically, that may have been your original intent














Hello,
On line 4 of your script do you mean
mkdir -p “$TM_BACKUP_DIR/$TM_DIRECTORY”
instead of
mkdir -p “$TM_BACKUP_DIR/$TM_DIRECTORY” ?
-Ryan