File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1313
1414# Define the directory where notes are stored
1515# NOTES_DIRECTORY=~/notes
16+
17+ # Define command to run after modification command
18+ # POST_COMMAND="/path/to/custom_script.sh"
Original file line number Diff line number Diff line change 316316main () {
317317 local ret=0
318318 local cmd=" "
319+ # variable to indicate whether it's a modification command
320+ local modified=0
319321
320322 if [ -z " $1 " ]; then
321323 printf " No command specified\n\n"
@@ -326,6 +328,7 @@ main() {
326328 case " $1 " in
327329 " new" |" n" )
328330 cmd=" new_note"
331+ modified=1
329332 ;;
330333 " ls" )
331334 cmd=" ls_notes"
@@ -341,15 +344,19 @@ main() {
341344 ;;
342345 " open" |" o" )
343346 cmd=" handle_multiple_notes open"
347+ modified=1
344348 ;;
345349 " append" |" a" )
346350 cmd=" append_note"
351+ modified=1
347352 ;;
348353 " mv" )
349354 cmd=" move_note"
355+ modified=1
350356 ;;
351357 " rm" )
352358 cmd=" remove_note"
359+ modified=1
353360 ;;
354361 " cat" )
355362 cmd=" handle_multiple_notes cat"
@@ -370,6 +377,12 @@ main() {
370377
371378 $cmd " $@ "
372379 ret=$[$ret +$? ]
380+
381+ # run POST_COMMAND hook when modification cmd succeeds
382+ if [ $ret -eq 0 ] && [ $modified -eq 1 ] && [ -n " $POST_COMMAND " ]; then
383+ eval " $POST_COMMAND "
384+ fi
385+
373386 exit $ret
374387}
375388main " $@ "
You can’t perform that action at this time.
0 commit comments