@@ -56,7 +56,8 @@ search_filenames_and_contents() {
5656 " shopt -s nocasematch
5757 grep -il \" $* \" \" {}\" || if [[ \" {}\" =~ \" $* \" ]]; then
5858 echo \" {}\" ;
59- fi" \; )
59+ fi" \; \
60+ )
6061 else
6162 find_output=$( find " $notes_dir " -type f)
6263 fi
@@ -104,11 +105,12 @@ grep_notes() {
104105
105106generate_name () {
106107 local append_num=0
107- local format_string=" $( date +$QUICKNOTE_FORMAT ) "
108+ local format_string=" ` date +$QUICKNOTE_FORMAT ` "
108109 # Initial test has no append
109110 local resolved_name=$format_string
110- while [[ -e " $notes_dir /$resolved_name .$NOTES_EXT " ]]; do
111- append_num=$(( $append_num + 1 ))
111+ while [[ -e " $notes_dir /$resolved_name .$NOTES_EXT " ]]
112+ do
113+ append_num=$[$append_num +1]
112114 resolved_name=$format_string .$append_num
113115 done
114116 printf $resolved_name
@@ -117,10 +119,10 @@ generate_name() {
117119new_note () {
118120 local note_name=" $* "
119121 if [[ $note_name == " " ]]; then
120- note_name=" $( generate_name) "
122+ note_name=" $( generate_name) "
121123 fi
122124
123- if echo " $note_name " | grep " /$" & > /dev/null; then
125+ if echo " $note_name " | grep " /$" & > /dev/null; then
124126 note_name=" ${note_name} /$( generate_name) "
125127 fi
126128
@@ -159,7 +161,7 @@ handle_multiple_notes() {
159161 read -d' \n' note_names
160162 while read note_name; do
161163 ${cmd} _note " $note_name "
162- done <<< " $note_names"
164+ done <<< " $note_names"
163165 else
164166 ${cmd} _note " ${@: 2} "
165167 fi
@@ -200,7 +202,7 @@ open_note() {
200202 exit 1
201203 fi
202204
203- note_path=$( get_full_note_path " $note_path " )
205+ note_path=$( get_full_note_path " $note_path " )
204206
205207 if bash -c " : >/dev/tty" > /dev/null 2> /dev/null; then
206208 $EDITOR " $note_path " < /dev/tty
@@ -210,7 +212,7 @@ open_note() {
210212}
211213
212214append_note () {
213- local source_note_path=$( get_full_note_path " $1 " )
215+ local source_note_path=$( get_full_note_path " $1 " )
214216 local to_append=" ${@: 2} "
215217
216218 # If no note name was provided, exit
@@ -235,11 +237,11 @@ append_note() {
235237 exit 1
236238 fi
237239
238- echo " $to_append " >> " $source_note_path "
240+ echo " $to_append " >> " $source_note_path "
239241}
240242
241243move_note () {
242- local source_note_path=$( get_full_note_path " $1 " )
244+ local source_note_path=$( get_full_note_path " $1 " )
243245 local dest_or_dir_path=$2
244246
245247 if [[ ! -e " $source_note_path " ]]; then
@@ -258,8 +260,8 @@ move_note() {
258260 return
259261 fi
260262
261- local dest_path=$( get_full_note_path " $dest_or_dir_path " )
262- mkdir -p " $( dirname $dest_path ) "
263+ local dest_path=$( get_full_note_path " $dest_or_dir_path " )
264+ mkdir -p " $( dirname $dest_path ) "
263265 mv $source_note_path $dest_path
264266}
265267
@@ -271,14 +273,14 @@ cat_note() {
271273 exit 1
272274 fi
273275
274- note_path=$( get_full_note_path " $note_path " )
276+ note_path=$( get_full_note_path " $note_path " )
275277
276278 cat " $note_path "
277279}
278280
279281usage () {
280- local name=$( basename $0 )
281- cat << EOF
282+ local name=$( basename $0 )
283+ cat << EOF
282284$name is a command line note taking tool.
283285
284286Usage:
305307}
306308
307309version () {
308- local name=$( basename $0 )
309- cat << EOF
310+ local name=$( basename $0 )
311+ cat << EOF
310312$name $notes_version
311313EOF
312314}
@@ -324,57 +326,57 @@ main() {
324326 fi
325327
326328 case " $1 " in
327- " new" | " n" )
328- cmd=" new_note"
329- modified=1
330- ;;
331- " ls" )
332- cmd=" ls_notes"
333- ;;
334- " search" | " s" )
335- cmd=" search_filenames_and_contents"
336- ;;
337- " find" | " f" )
338- cmd=" find_notes"
339- ;;
340- " grep" | " g" )
341- cmd=" grep_notes"
342- ;;
343- " open" | " o" )
344- cmd=" handle_multiple_notes open"
345- modified=1
346- ;;
347- " append" | " a" )
348- cmd=" append_note"
349- modified=1
350- ;;
351- " mv" )
352- cmd=" move_note"
353- modified=1
354- ;;
355- " rm" )
356- cmd=" remove_note"
357- modified=1
358- ;;
359- " cat" | " c" )
360- cmd=" handle_multiple_notes cat"
361- ;;
362- --help | -help | -h)
363- cmd=" usage"
364- ;;
365- --version | -version)
366- cmd=" version"
367- ;;
368- * )
369- printf " $1 is not a recognized notes command.\n\n"
370- cmd=" usage"
371- ret=1
372- ;;
329+ " new" | " n" )
330+ cmd=" new_note"
331+ modified=1
332+ ;;
333+ " ls" )
334+ cmd=" ls_notes"
335+ ;;
336+ " search" | " s" )
337+ cmd=" search_filenames_and_contents"
338+ ;;
339+ " find" | " f" )
340+ cmd=" find_notes"
341+ ;;
342+ " grep" | " g" )
343+ cmd=" grep_notes"
344+ ;;
345+ " open" | " o" )
346+ cmd=" handle_multiple_notes open"
347+ modified=1
348+ ;;
349+ " append" | " a" )
350+ cmd=" append_note"
351+ modified=1
352+ ;;
353+ " mv" )
354+ cmd=" move_note"
355+ modified=1
356+ ;;
357+ " rm" )
358+ cmd=" remove_note"
359+ modified=1
360+ ;;
361+ " cat" | " c" )
362+ cmd=" handle_multiple_notes cat"
363+ ;;
364+ --help | -help | -h )
365+ cmd=" usage"
366+ ;;
367+ --version | -version )
368+ cmd=" version"
369+ ;;
370+ * )
371+ printf " $1 is not a recognized notes command.\n\n"
372+ cmd=" usage"
373+ ret=1
374+ ;;
373375 esac
374376 shift
375377
376378 $cmd " $@ "
377- ret=$(( $ret + $? ))
379+ ret=$[ $ret + $? ]
378380
379381 # run POST_COMMAND hook when modification cmd succeeds
380382 if [ $ret -eq 0 ] && [ $modified -eq 1 ] && [ -n " $POST_COMMAND " ]; then
@@ -384,3 +386,4 @@ main() {
384386 exit $ret
385387}
386388main " $@ "
389+
0 commit comments