Skip to content

Instantly share code, notes, and snippets.

@peterchappell
Forked from sippey/LogIt.scpt
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterchappell/cfe1cc3809d1d1835fb5 to your computer and use it in GitHub Desktop.
Save peterchappell/cfe1cc3809d1d1835fb5 to your computer and use it in GitHub Desktop.
applescript for use with quicksilver to log text with date and timestamp

This is a simple AppleScript designed for use with QuickSilver to log text to a file with a date and timestamp.

Instructions for use...

  • Edit the script to set your file path appropriately. Mine is set to write output to my "log.txt" file in my "taskpaper" folder under Dropbox.
  • Open up script editor, paste in the script.
  • Save it to your ~/Library/Application Support/Quicksilver/Actions folder as something like LogIt.scpt. If the actions folder doesn't exist, go ahead and create it.
  • Restart Quicksilver.
  • Invoke Quicksilver, type ".", type your text, TAB, type "LogIt", hit enter. Voila, your text is appended to your log file with the date & timestamp at the beginning of the line.

For bonus points, set the "Open With..." setting on your log file to always open with the Console app. That way, when you view this file, you'll have quick access tools for filtering and searching through the file.

using terms from application "Quicksilver"
on process text log_text
set theDate to (do shell script "date '+%A %d-%m-%Y'")
set theTime to (do shell script "date '+%H:%M'")
set theText to log_text
if (log_text is equal to "start") then
set theText to "
---
" & theDate & "
---
"
else
set theText to "
" & theTime & "
" & log_text & "
"
end if
set thePosixFilePath to "/Users/chappellp8b/Documents/_log/log.txt" as string
set theFilePath to POSIX file thePosixFilePath
set theFileReference to open for access theFilePath with write permission
write theText to theFileReference starting at eof
close access theFileReference
end process text
end using terms from
@peterchappell
Copy link
Author

I've modified the original script so that if you log "start" it renders today's date as a delimiter, otherwise it logs your text as a timestamped entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment