-
-
Save borkxs/daabaa7afdaef9daffb5 to your computer and use it in GitHub Desktop.
Command line tool for logging random timestamped notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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