Skip to content

Instantly share code, notes, and snippets.

@valvallow
Last active September 30, 2015 03:48
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 valvallow/1716983 to your computer and use it in GitHub Desktop.
Save valvallow/1716983 to your computer and use it in GitHub Desktop.
shellmemo
#!/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