-
-
Save tspoke/932c7e408b19e85eb3f90e471fb76a92 to your computer and use it in GitHub Desktop.
Simple monkey coded memo for terminal
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/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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x memo
export PATH=$PATH:~/your-folder
Commands :