From 5595885bbc19d53284804af84012b9f650eec852 Mon Sep 17 00:00:00 2001 From: dmarakom6 Date: Mon, 5 Jul 2021 15:49:58 +0300 Subject: [PATCH] Fix directory bug Fix not getting back to starting dir --- util/delnote.sh | 2 ++ util/findmisplacednote.sh | 2 ++ util/findnote.sh | 1 + util/listnotes.sh | 3 ++- util/newnote.sh | 5 ++--- util/notewc.sh | 1 + util/quicknote.sh | 1 + util/quickread.sh | 16 +++++++++++++--- util/readnote.sh | 1 + util/renamenote.sh | 1 + 10 files changed, 26 insertions(+), 7 deletions(-) diff --git a/util/delnote.sh b/util/delnote.sh index b6b7dcc..b5b0fd4 100644 --- a/util/delnote.sh +++ b/util/delnote.sh @@ -6,6 +6,7 @@ in /docs/github/ for its full text. info function delnote() { + DIR="$(pwd)" if [ $# -eq 0 ]; then echo -n "Enter the name of the note you want to delete: " && read delete else @@ -42,4 +43,5 @@ function delnote() { fi fi fi +cd $DIR } \ No newline at end of file diff --git a/util/findmisplacednote.sh b/util/findmisplacednote.sh index 17ec22d..8506350 100644 --- a/util/findmisplacednote.sh +++ b/util/findmisplacednote.sh @@ -6,6 +6,7 @@ in /docs/github/ for its full text. info function findmisplacednote() { + DIR="$(pwd)" if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename else @@ -19,4 +20,5 @@ function findmisplacednote() { echo "Possible locations: " find ~/ -iname $notename -print 2>/dev/null fi + cd $DIR } \ No newline at end of file diff --git a/util/findnote.sh b/util/findnote.sh index 1dad879..3621491 100644 --- a/util/findnote.sh +++ b/util/findnote.sh @@ -6,6 +6,7 @@ in /docs/github/ for its full text. info function findnote() { + DIR="$(pwd)" if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename else diff --git a/util/listnotes.sh b/util/listnotes.sh index ea2c9ac..5a7c539 100644 --- a/util/listnotes.sh +++ b/util/listnotes.sh @@ -6,7 +6,7 @@ in /docs/github/ for its full text. info function listnotes() { - + DIR="$(pwd)" listnotesFunc () { NOTES="`ls $DEFAULT_PATH --color=always `" @@ -42,4 +42,5 @@ function listnotes() { fi esac return 0 + cd $DIR } diff --git a/util/newnote.sh b/util/newnote.sh index 27d694c..c903e38 100644 --- a/util/newnote.sh +++ b/util/newnote.sh @@ -6,13 +6,12 @@ in /docs/github/ for its full text. info function newnote() { - + DIR="$(pwd)" cd $DEFAULT_PATH $NOTES_EDITOR clear - cd $DIR str="Note created in $DEFAULT_PATH" underlines=$(echo "$str" | tr -c '\010' '-') echo "$str\n$underlines" - + cd $DIR } \ No newline at end of file diff --git a/util/notewc.sh b/util/notewc.sh index 5f26dae..bac9337 100644 --- a/util/notewc.sh +++ b/util/notewc.sh @@ -6,6 +6,7 @@ in /docs/github/ for its full text. info function notewc() { + DIR="$(pwd)" if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename else diff --git a/util/quicknote.sh b/util/quicknote.sh index 4e9d1e8..093dc0f 100644 --- a/util/quicknote.sh +++ b/util/quicknote.sh @@ -6,6 +6,7 @@ in /docs/github/ for its full text. info function quicknote() { + DIR="$(pwd)" if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename else diff --git a/util/quickread.sh b/util/quickread.sh index 41f27a4..7e43a66 100644 --- a/util/quickread.sh +++ b/util/quickread.sh @@ -6,23 +6,33 @@ in /docs/github/ for its full text. info function quickread() { + DIR="$(pwd)" + check_params() { + case $1 in + -parameter | --parameter ) + + ;; + esac + return 0 + } if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename + elif [ $# -gt 1 ]; then + check_params else notename=$1 fi + cd $DEFAULT_PATH if [ -e $notename ]; then clear - - if [ "$(cat $notename | wc -l)" -ge 25 ];then + if [ "$(cat $notename | wc -l)" -ge 25 ]; then cat $notename | less else cat $notename fi else - clear echo "No such note." fi diff --git a/util/readnote.sh b/util/readnote.sh index be5d19d..b92f218 100644 --- a/util/readnote.sh +++ b/util/readnote.sh @@ -6,6 +6,7 @@ in /docs/github/ for its full text. info function readnote() { + DIR="$(pwd)" if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename else diff --git a/util/renamenote.sh b/util/renamenote.sh index bc88073..c0eafea 100644 --- a/util/renamenote.sh +++ b/util/renamenote.sh @@ -6,6 +6,7 @@ in /docs/github/ for its full text. info function renamenote() { + DIR="$(pwd)" cd $DEFAULT_PATH if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename