diff --git a/note b/note index 5bd2367..faac67c 100644 --- a/note +++ b/note @@ -1,28 +1,100 @@ #!/bin/bash -# Check if there is any arguments, if there is then append all of it. -if [ "$1" == "less" ]; then - less ~/notefile +author="Livila" +version="2.0" +filename=~/notefile +para="$1" + + +if [ "$1" == "--setfile" ]; then + # Check if the file location is entered, exit if not. + if [[ -z $2 ]]; then + exit 1 + fi + filename=$2 + para=$3 +fi + +# Check if there is any arguments, if there is append all of it. +if [ "$para" == "--less" ]; then + less $filename exit 1 -elif [ "$1" != "" ]; then - date >> ~/notefile - echo "$@" >> ~/notefile +elif [ "$para" == "--edit" ]; then + vi $filename + exit 1 +elif [ "$para" == "--vi" ]; then + vi $filename + exit 1 +elif [ "$para" == "--gedit" ]; then + gedit $filename + exit 1 +elif [ "$para" == "--location" ]; then + echo "$filename"; + exit 1 +elif [ "$para" == "--author" ]; then + echo "The author of this program is $author."; + exit 1 +elif [ "$para" == "--version" ]; then + echo "Version $version"; + exit 1 +elif [ "$para" == "--help" ]; then + + + echo -e 'Usage: + note [--setfile ] [--less|--vi|--gedit|--help|--author|--version] + +Commands: + --setfile: Set new temporary location of file + --less Show contents using "less" + --vi Edit contents using "vi" + --gedit Edit contents using "gedit" + --location Show file location + --help Show this help message + --author Show the author + --version Show current version + +Examples: + note --setfile + Will open note just as before, but using instead. + + note --setfile --less + Will show using the less command. +'; + exit 1 + + +elif [ "$para" != "" ]; then + date >> $filename + if [ "$1" == "--setfile" ]; then + # Start from the third input parameter and write to the file. + echo "${@:3}" >> $filename + else + # Write all parameters entered to the file. + echo "$@" >> $filename + fi exit 1 fi -echo 'Enter input or type :exit or :q to exit. Type :less to show the notefile.' +echo 'Enter input or type :exit or :q to exit. :less to show contents.' read input -if [ "$input" != ":exit" ] && [ "$input" != ":q" ]; then - date >> ~/notefile -fi +saveDateOnce=0 +# Loop until :exit or :q is entered. while [ "$input" != ":exit" ] && [ "$input" != ":q" ]; do + # In case you want to have a quick overview of your text. if [ "$input" == ":less" ]; then - less ~/notefile + less $filename else - echo "$input" >> ~/notefile + # Check if the date has been saved. + if [ $saveDateOnce == 0 ]; then + date >> $filename + saveDateOnce=1 + fi + echo "$input" >> $filename fi + read input done +