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 13
13
14
14
# Define the directory where notes are stored
15
15
# 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 316
316
main () {
317
317
local ret=0
318
318
local cmd=" "
319
+ # variable to indicate whether it's a modification command
320
+ local modified=0
319
321
320
322
if [ -z " $1 " ]; then
321
323
printf " No command specified\n\n"
@@ -326,6 +328,7 @@ main() {
326
328
case " $1 " in
327
329
" new" |" n" )
328
330
cmd=" new_note"
331
+ modified=1
329
332
;;
330
333
" ls" )
331
334
cmd=" ls_notes"
@@ -341,15 +344,19 @@ main() {
341
344
;;
342
345
" open" |" o" )
343
346
cmd=" handle_multiple_notes open"
347
+ modified=1
344
348
;;
345
349
" append" |" a" )
346
350
cmd=" append_note"
351
+ modified=1
347
352
;;
348
353
" mv" )
349
354
cmd=" move_note"
355
+ modified=1
350
356
;;
351
357
" rm" )
352
358
cmd=" remove_note"
359
+ modified=1
353
360
;;
354
361
" cat" )
355
362
cmd=" handle_multiple_notes cat"
@@ -370,6 +377,12 @@ main() {
370
377
371
378
$cmd " $@ "
372
379
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
+
373
386
exit $ret
374
387
}
375
388
main " $@ "
You can’t perform that action at this time.
0 commit comments