@@ -56,8 +56,7 @@ search_filenames_and_contents() {
5656 " shopt -s nocasematch
5757 grep -il \" $* \" \" {}\" || if [[ \" {}\" =~ \" $* \" ]]; then
5858 echo \" {}\" ;
59- fi" \; \
60- )
59+ fi" \; )
6160 else
6261 find_output=$( find " $notes_dir " -type f)
6362 fi
@@ -105,12 +104,11 @@ grep_notes() {
105104
106105generate_name () {
107106 local append_num=0
108- local format_string=" ` date +$QUICKNOTE_FORMAT ` "
107+ local format_string=" $( date +$QUICKNOTE_FORMAT ) "
109108 # Initial test has no append
110109 local resolved_name=$format_string
111- while [[ -e " $notes_dir /$resolved_name .$NOTES_EXT " ]]
112- do
113- append_num=$[$append_num +1]
110+ while [[ -e " $notes_dir /$resolved_name .$NOTES_EXT " ]]; do
111+ append_num=$(( $append_num + 1 ))
114112 resolved_name=$format_string .$append_num
115113 done
116114 printf $resolved_name
@@ -119,10 +117,10 @@ generate_name() {
119117new_note () {
120118 local note_name=" $* "
121119 if [[ $note_name == " " ]]; then
122- note_name=" $( generate_name) "
120+ note_name=" $( generate_name) "
123121 fi
124122
125- if echo " $note_name " | grep " /$" & > /dev/null; then
123+ if echo " $note_name " | grep " /$" & > /dev/null; then
126124 note_name=" ${note_name} /$( generate_name) "
127125 fi
128126
@@ -161,7 +159,7 @@ handle_multiple_notes() {
161159 read -d' \n' note_names
162160 while read note_name; do
163161 ${cmd} _note " $note_name "
164- done <<< " $note_names"
162+ done <<< " $note_names"
165163 else
166164 ${cmd} _note " ${@: 2} "
167165 fi
@@ -202,7 +200,7 @@ open_note() {
202200 exit 1
203201 fi
204202
205- note_path=$( get_full_note_path " $note_path " )
203+ note_path=$( get_full_note_path " $note_path " )
206204
207205 if bash -c " : >/dev/tty" > /dev/null 2> /dev/null; then
208206 $EDITOR " $note_path " < /dev/tty
@@ -212,7 +210,7 @@ open_note() {
212210}
213211
214212append_note () {
215- local source_note_path=$( get_full_note_path " $1 " )
213+ local source_note_path=$( get_full_note_path " $1 " )
216214 local to_append=" ${@: 2} "
217215
218216 # If no note name was provided, exit
@@ -237,11 +235,11 @@ append_note() {
237235 exit 1
238236 fi
239237
240- echo " $to_append " >> " $source_note_path "
238+ echo " $to_append " >> " $source_note_path "
241239}
242240
243241move_note () {
244- local source_note_path=$( get_full_note_path " $1 " )
242+ local source_note_path=$( get_full_note_path " $1 " )
245243 local dest_or_dir_path=$2
246244
247245 if [[ ! -e " $source_note_path " ]]; then
@@ -260,8 +258,8 @@ move_note() {
260258 return
261259 fi
262260
263- local dest_path=$( get_full_note_path " $dest_or_dir_path " )
264- mkdir -p " $( dirname $dest_path ) "
261+ local dest_path=$( get_full_note_path " $dest_or_dir_path " )
262+ mkdir -p " $( dirname $dest_path ) "
265263 mv $source_note_path $dest_path
266264}
267265
@@ -273,14 +271,14 @@ cat_note() {
273271 exit 1
274272 fi
275273
276- note_path=$( get_full_note_path " $note_path " )
274+ note_path=$( get_full_note_path " $note_path " )
277275
278276 cat " $note_path "
279277}
280278
281279usage () {
282- local name=$( basename $0 )
283- cat << EOF
280+ local name=$( basename $0 )
281+ cat << EOF
284282$name is a command line note taking tool.
285283
286284Usage:
@@ -294,7 +292,7 @@ Usage:
294292 $name append|a <name> [message] # Appends a note. Will use stdin if no message is given
295293 $name mv <source> <dest>|<directory> # Rename a note, or move a note when a directory is given
296294 $name rm [-r | --recursive] <name> # Remove note, or folder if -r or --recursive is given
297- $name cat <name> # Display note
295+ $name cat|c <name> # Display note
298296 echo <name> | $name open|o # Open all note filenames piped in
299297 echo <name> | $name cat # Display all note filenames piped in
300298 $name --help # Print this usage information
307305}
308306
309307version () {
310- local name=$( basename $0 )
311- cat << EOF
308+ local name=$( basename $0 )
309+ cat << EOF
312310$name $notes_version
313311EOF
314312}
@@ -326,57 +324,57 @@ main() {
326324 fi
327325
328326 case " $1 " in
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" )
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- ;;
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+ ;;
375373 esac
376374 shift
377375
378376 $cmd " $@ "
379- ret=$[ $ret + $? ]
377+ ret=$(( $ret + $? ))
380378
381379 # run POST_COMMAND hook when modification cmd succeeds
382380 if [ $ret -eq 0 ] && [ $modified -eq 1 ] && [ -n " $POST_COMMAND " ]; then
@@ -386,4 +384,3 @@ main() {
386384 exit $ret
387385}
388386main " $@ "
389-
0 commit comments