Skip to content

Instantly share code, notes, and snippets.

@corypina
Last active December 19, 2015 17:49
Show Gist options
  • Save corypina/5994564 to your computer and use it in GitHub Desktop.
Save corypina/5994564 to your computer and use it in GitHub Desktop.
Creates and opens timestamped text file into predetermined folder to be used for any kind of journaling. Example: "2013.07.14.800.txt" with first line reading "July 14, 2013 8:00 AM."
-- Set path to your folder here, including trailing slash and quotes.
set pathtofolder to "~/Dropbox/Write/"
-- Set preferred text editor here, including quotes.
-- Works with TextEdit, TextMate, TextWrangler, and I assume most others.
set myEditor to "Textmate"
-- Assigns bash script to variablle `ss`.
-- NOW = Current date and 24-hour time used for a sortable filename.
-- FULLDATE = Current wekday, date, and 12-hour time used for first line of journal entry.
-- First `echo` creates new document in your folder using the above variables.
-- Second `echo` adds an extra carriage return to that file.
-- Last line opens file in text editor.
set ss to "NOW=$(date \"+%Y.%m.%d.%H%M\")
FULLDATE=$(date \"+%B %d, %Y %I:%M %p\")
echo $FULLDATE > " & pathtofolder & "$NOW.txt
echo '\\r' >> " & pathtofolder & "$NOW.txt
open -a " & myEditor & " " & pathtofolder & "$NOW.txt"
-- Runs the script and brings text editor to front.
do shell script ss
tell application myEditor to activate
-- Tells text editor to put cursor at the last line, so you can type immediately.
tell application "System Events" to tell process myEditor to keystroke (ASCII character 31) using command down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment