How Tos: Auto Save Copy for TextMate
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
# 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 (<STDIN>) { print $_; }’ > "$TM_BACKUP_DIR/$THEDATE/$TM_FILENAME.$THEDATE.$THETIME.backup"
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.
# 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/<b>$TM_DIRECTORY</b>" perl -e ‘while (<STDIN>) { print $_; }’ > "$TM_BACKUP_DIR/<b>$TM_DIRECTORY</b>/$THEDATE.$THETIME_$TM_FILENAME"













