Saving terminal scrollback to evernote

I tend to keep a log of things I did when operating on production systems. It took quite a few steps to get this done, so I automated my workflow with a bash script.

This script will put the current scrollback buffer into a temp file and import that file into evernote. I am aware I can paste the buffer directly into the note but I prefer the way evernote reacts when you type the save command, it will prompt you for a title.

Enjoy.

#!/bin/sh
#
# Author: arijan.luiken at ryoku.org
#
osascript << @EOF
set fp to "/tmp/terminal.txt"

tell application "Terminal"
	activate
	set buffer to history of front window as text
end tell

try
	open for access fp with write permission
	set eof of fp to 0
	write (buffer) to fp starting at eof
	close access fp
on error
	try
		close access fp
	end try
end try

tell application "Evernote"
	activate
	create note from file fp tags "#terminal"
end tell
@EOF

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">