Skip to content

Instantly share code, notes, and snippets.

@borkxs
Last active August 29, 2015 14:14
Show Gist options
  • Save borkxs/daabaa7afdaef9daffb5 to your computer and use it in GitHub Desktop.
Save borkxs/daabaa7afdaef9daffb5 to your computer and use it in GitHub Desktop.
Command line tool for logging random timestamped notes
#!/bin/sh
helptext="
\nUsage: note <text>
\n \tor note <flag>
\n
\nwhere <text> is any number of arguments to be appended to the note log
\n
\nand where <flag> is one of:
\n
\n \t-v \tviews the last n lines (can be changed in script)
\n \t-o \topens the note in Sublime Text (my preference)
\n \t-d \tarchives the note to a timestamped file
\n \t \tand replaces it with a blank file
\n
\n
"
path=~/Documents
name=.notes
ext=txt
file=$path/$name.$ext
n=50
NOW=$(date +"%m/%d/%Y %H:%M:%S")
NOWB=$(date +"%m-%d-%Y-%H-%M-%S")
if [[ $1 = "-v" ]]; then
tail -n $n $file && echo ""
elif [[ $1 = "-o" ]]; then
subl $file
elif [[ $1 = "-d" ]]; then
mv $file $path/.note.$NOWB.$ext && echo "" > $file
elif [[ $1 = "-n" ]]; then
tail -n $(($2 * 3)) $file && echo ""
elif [[ $1 = "-h" ]]; then
echo $helptext
elif [[ $1 = "help" ]]; then
echo $helptext
elif [ $# -eq 0 ]; then
echo $helptext
else
echo '\n'$NOW'>\n'"$@" >> $file
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment