Skip to content

Instantly share code, notes, and snippets.

@tspoke
Last active July 25, 2017 14:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tspoke/932c7e408b19e85eb3f90e471fb76a92 to your computer and use it in GitHub Desktop.
Save tspoke/932c7e408b19e85eb3f90e471fb76a92 to your computer and use it in GitHub Desktop.
Simple monkey coded memo for terminal
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
EXPORT_FILE=$DIR'/memo-save.txt'
READ_ONLY=1
for param in "$@"
do
if [ $param = "edit" ]
then
READ_ONLY=0
echo "Opening editor..."
nano $EXPORT_FILE
exit 0;
elif [ $param = "add" ]
then
READ_ONLY=0
echo "New memo (enter to validate):"
read toadd
echo $toadd >> $EXPORT_FILE
echo "Entry saved : $toadd"
elif [ $param = "clear" ]
then
READ_ONLY=0
read -p "Do you really want to clear all your notes ? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "# Memo" > $EXPORT_FILE
echo "Memo cleared !"
fi
elif [ $param = "help" ] || [ $param = "?" ]
then
READ_ONLY=0
echo "########################################################################"
echo "# HELP || Available commands for '$ memo'"
echo "########################################################################"
echo "# With no params, will show up the memo content"
echo "#"
echo "# edit Allow you to delete all your note in an editor"
echo '# add Add a new entry'
echo "# clear Delete all your notes"
fi
done
if [ $READ_ONLY = 1 ]
then
cat $EXPORT_FILE
fi
exit 0;
@tspoke
Copy link
Author

tspoke commented Jul 25, 2017

  • Put this script in a file in a folder
  • chmod +x memo
  • Add the folder to your path export PATH=$PATH:~/your-folder
  • Use it !

Commands :

memo             # show the content of the memo
memo edit      # edit with nano
memo clear    # delete all entries
memo add      # add an entry
memo help     # help 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment