Last active
September 30, 2015 03:48
-
-
Save valvallow/1716983 to your computer and use it in GitHub Desktop.
shellmemo
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 | |
MEMO_PATH="$HOME"/.shellmemo | |
TAG_NAMES="" | |
usage () { | |
echo 'Usage:memo [-dth] <memo>' | |
echo ' -d : display memo records' | |
echo ' -t : tag' | |
echo ' -c : clear' | |
echo ' -h : help' | |
exit 0 | |
} | |
display () { | |
cat "$MEMO_PATH" | |
exit 0 | |
} | |
if [ "$#" -eq 0 ] ; then | |
# usage | |
display | |
fi | |
while getopts hcdt: OPT | |
do | |
case $OPT in | |
"t" ) TAG_NAMES='['"$OPTARG"']' ; shift ;; | |
"c" ) CLEAR="TRUE" ;; | |
"d" ) display ;; | |
"h" ) usage ;; | |
esac | |
done | |
if [ "$CLEAR" = "TRUE" ]; then | |
echo -n '' > $MEMO_PATH | |
else | |
echo `date +"%Y-%m-%d %H:%M:%S"` "$TAG_NAMES" "$1" >> $MEMO_PATH | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment