-
Notifications
You must be signed in to change notification settings - Fork 1
/
notes
executable file
·770 lines (629 loc) · 19 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
#!/bin/sh
#
# STANDARD(?) UNIX NOTES
#
# This is Unix Notes. An GPG encrypted notes system designed for privacy
#
# The idea came from 'pass' the standard Unix password manager
# VARIABLES
VERSION=2.5
#NOTES_UMASK='077'
# Handle $XDG_DATA_DIR -or- NOTESDIR being set in environment
if [ -n "$XDG_DATA_DIR" -a -z "$NOTESDIR" ] ; then
# only use $XDG_DATA_DIR if NOTESDIR not set
NOTESDIR="${XDG_DATA_DIR}/.notes"
else
# use NOTESDIR if set else default to ~/.notes
NOTESDIR="${NOTESDIR:-${HOME}/.notes}"
fi
CONFIGFILE="${NOTESDIR}/config"
INITIAL_NOTEBOOK="${NOTESDIR}/notes"
DEFAULT_POINTER="${NOTESDIR}/DEFAULT"
USE_POINTER="${NOTESDIR}/USE"
DIRFORDIARY="${NOTESDIR}/Journal"
JOURNALDIR="${JOURNALDIR:-$DIRFORDIARY}"
GPGKEY=''
GPG_OPTS=" --quiet --yes --compress-algo=none --no-encrypt-to"
GPG="gpg"
GITCMD="git -C ${NOTESDIR} "
GITADD="git -C ${NOTESDIR} add "
GITCOMMIT="git -C ${NOTESDIR} commit -m "
GITLOG="git -C ${NOTESDIR} log"
GITSTATUS="git -C ${NOTESDIR} status"
EDITOR="${EDITOR:-nano}"
PAGER="${PAGER:-more}"
TIMESTAMP="`date \"+%Y%m%d_%H%M\"`"
BACKUPFILE="${HOME}/unix-notes-backup-${TIMESTAMP}.tar.asc"
# Use shred if available
SHRED="`which shred`"
if [ $? = 0 ]; then
SHREDCMD="${SHRED} --remove=wipe"
else
SHREDCMD="rm"
fi
USEGIT="`grep git ${CONFIGFILE}| cut -d'=' -f 2`"
spell_check () {
SPELLCHECK="`grep spelling ${CONFIGFILE} | cut -d '=' -f 2`"
case ${SPELLCHECK} in
aspell)
aspell -x -c ${notefile}
;;
ispell)
ispell -x ${notefile}
;;
esac
}
# initialise notes system
#
cmd_init (){ # setup directories and GPG key to be used
umask "${NOTES_UMASK:-077}"
if [ ! -d "$NOTESDIR" ]; then
echo Creating notes directory: $NOTESDIR
mkdir -p $NOTESDIR
fi
create_config $1
echo making default notebook \'${INITIAL_NOTEBOOK}\'
if [ ! -d "$INITIAL_NOTEBOOK" ]; then
mkdir $INITIAL_NOTEBOOK
echo Your default notebook $INITIAL_NOTEBOOK has been created you may now create notes
# point to INITIAL_NOTEBOOK with DEFAULT_POINTER and USE_POINTER
if [ ! -f "$DEFAULT_POINTER" ] ; then
ln -s "`basename $INITIAL_NOTEBOOK`" "$DEFAULT_POINTER"
fi
if [ ! -f "$USE_POINTER" ] ; then
ln -s "`basename $INITIAL_NOTEBOOK`" "$USE_POINTER"
fi
fi
echo "Creating Journal directory ${JOURNALDIR} "
mkdir -p $JOURNALDIR
}
create_config () {
touch $CONFIGFILE
chmod 600 $CONFIGFILE
echo You have the following private keys on your keyring
gpg -K
if [ "`gpg -K | wc -l`" = "0" ] ; then
echo No Private keys in keyring ... aborting
exit 1
fi
echo By DEFAULT we will use the first key found as the key for encrypting
echo If this is NOT what is required please edit $NOTESDIR/config to
echo reflect the recipient you wish to use
echo You will need to edit the KEY parameter and set it to the email
echo address of the key you wish to use
KEY="`gpg -K --with-colons | grep fpr | head -1 | tr -d 'fpr:::::::::' `"
echo "KEY $KEY" > $CONFIGFILE
echo ""
echo Do you want spellchecking enabled?
echo "1) Use aspell"
echo "2) Use ispell"
echo "3) Do not spell check"
read -p "Choose 1,2,or 3: " choosespell
case $choosespell in
1)
echo "spelling=aspell" >> $CONFIGFILE
;;
2)
echo "spelling=ispell" >> $CONFIGFILE
;;
*)
echo "spelling=none" >> $CONFIGFILE
;;
esac
echo ""
if [ "$1" = "git" ]; then
echo "git=y" >> $CONFIGFILE
echo Setting up local git repo
${GITCMD} init -q ${NOTESDIR}
echo ""
fi
echo Default config written:
cat $CONFIGFILE
}
get_recipient () {
KEY=`grep KEY ${CONFIGFILE}| sed s/^KEY// | tr -d [:blank:]`
}
get_gpg_keyid () {
newkeyid="$1"
echo newkeyid supplied $newkeyid
if [ "$newkeyid" != "" ] ; then
validate_gpg_keyid $newkeyid
echo valid gpg key $newkeyid
else
echo No key supplied:
exit 1
fi
}
validate_gpg_keyid () {
testkey="$1"
keyids="/tmp/keyids.$$"
gpg --list-secret-keys --with-colons --keyid-format short | grep sec | cut -d':' -f 5 > $keyids
# test key character length = the last 16 (short) or the full 40 (long) are acceptable
case ${#testkey} in
16|40)
shortkey="`echo ${testkey} | tail -c 17`"
if [ "`grep ${shortkey} ${keyids}`" = "0" ] ; then
echo Invalid GPG keyid
cat $keyids
echo \n\n Type 'gpg -k <keyid> to find out more about key'
${SHREDCMD} $keyids
exit 1
else
echo Valid key $testkey
fi
;;
*)
echo Provided key is invalid: keys should be 16 or 40 characters
echo Valid keys are ...
cat $keyids
echo \n\n Type 'gpg -k <keyid> to find out more about key'
${SHREDCMD} $keyids
exit 1;;
esac
}
#
# note functions
#
note_add () {
filen="$@"
notefile="${USE_POINTER}/`echo ${filen} | tr ' ' '_'`"
if [ "$filen" = "" ] ; then
echo No notefile name given ... exiting
exit 1
fi
if [ -f "${notefile}.asc" ] ; then
echo File exists ... cannot create. Try 'notes edit' instead.
exit 1
else
get_recipient
touch "$notefile"
# create temporary note file
$EDITOR "$notefile"
spell_check
# encrypt note file
$GPG -ear $KEY $GPG_OPTS "$notefile"
${SHREDCMD} "$notefile"
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Added ${notefile}" > /dev/null
fi
}
note_import () {
toimport="$@"
pathname="`dirname ${toimport}`"
notefile="`basename ${toimport}`"
target="`echo ${notefile} | tr ' ' '_'`"
get_recipient
if [ -f "${toimport}" ] ; then
$GPG -ear $KEY $GPG_OPTS -o "${USE_POINTER}/${target}.asc" "${toimport}"
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Imported ${notefile}" > /dev/null
fi
}
note_view () {
notefile="`echo $@ | tr ' ' '_'`"
notefile="${USE_POINTER}/${notefile}"
get_recipient
if [ -f "${notefile}" ]; then
gpg -d "${notefile}"
elif [ -f "${notefile}.asc" ]; then
gpg -d "${notefile}.asc"
else
echo Note file does not exist
exit 1
fi
}
note_edit () {
notefile="`echo $@ | tr ' ' '_'`"
notefile="${USE_POINTER}/${notefile}"
decrypted="`echo ${notefile} | sed s/.asc//`"
get_recipient
if [ -f "$notefile" ]; then
gpg -d -o "${decrypted}" "${notefile}"
${EDITOR} "${decrypted}"
spell_check
$GPG -ear $KEY $GPG_OPTS "${decrypted}"
${SHREDCMD} ${decrypted}
elif [ -f "${notefile}.asc" ]; then
gpg -d -o "${decrypted}" "${notefile}.asc"
${EDITOR} "${decrypted}"
spell_check
$GPG -ear $KEY $GPG_OPTS "${decrypted}"
${SHREDCMD} ${decrypted}
else
echo Note file does not exist
exit 1
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Edited ${notefile}" > /dev/null
fi
}
note_list () {
ls "${USE_POINTER}" | column
}
note_delete () {
notefile="`echo $@ | tr ' ' '_'`"
notefile="${USE_POINTER}/${notefile}"
if [ -f "$notefile" ]; then
${SHREDCMD} "$notefile"
elif [ -f "${notefile}.asc" ]; then
${SHREDCMD} "${notefile}.asc"
else
echo Note file does not exist
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Deleted ${notefile}" > /dev/null
fi
}
note_rename () {
MVCP="$1"
shift
notefile="`echo $@ | tr ' ' '_'`"
notefile="${USE_POINTER}/${notefile}"
read -p "Please enter new name for note: " newname
newname="`echo ${newname} | tr ' ' '_'`"
case $notefile in
*gpg) skip;;
*) notefile="${notefile}.asc"
esac
newnotefile="${USE_POINTER}/${newname}"
case $newnotefile in
*gpg) skip;;
*) newnotefile="${newnotefile}.asc"
esac
case $MVCP in
"cp") processing="Copying ";;
"mv") processing="Moving ";;
esac
if [ -f "$notefile" ] ; then
echo $notefile exists .... $processing
$MVCP "$notefile" "$newnotefile"
elif [ -f "${notefile}.asc" ] ; then
echo $notefile exists .... $processing
$MVCP "$notefile" "$newnotefile"
else
echo Note $notefile does not exist, aborting...
exit 1
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "${processing} ${notefile} to ${newnotefile}" > /dev/null
fi
}
#
# notebook functions
#
notebook_add () {
notebookname="$@"
new_notebook="${NOTESDIR}/`echo ${notebookname} | tr ' ' '_'`"
if [ ! -d "$new_notebook" ] ; then
mkdir "$new_notebook"
chmod 700 "$new_notebook"
echo Created new notebook called $new_notebook
else
echo Notebook exists ... cannot create
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Added ${new_notebook}" > /dev/null
fi
}
notebook_delete () {
notebook="${NOTESDIR}/$@"
if [ ! -d "${notebook}" ] ; then
echo Error: Notebook \'$notebook\' does not exist
exit 1
else
rm -rf $notebook
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Deleted ${new_notebook}" > /dev/null
fi
}
notebook_rename () {
MVCP="$1"
shift
if [ "$MVCP" = "cp" ] ; then
MVCP="cp -r "
fi
notebook="$NOTESDIR/$@"
read -p "Please enter new name for note: " newname
newname="`echo ${newname} | tr ' ' '_'`"
newnotebook="${NOTESDIR}/${newname}"
case $MVCP in
"cp") processing="copying ";;
"mv") processing="moving ";;
esac
if [ -d "$notebook" ] ; then
echo $notebook exists .... $processing
$MVCP "$notebook" "$newnotebook"
else
echo Note $notebook does not exist, aborting...
exit 1
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Renamed ${notebook} to ${new_notebook}" > /dev/null
fi
}
notebook_list () {
ls "${NOTESDIR}" | sed 's/DEFAULT//; s/USE//; s/config//' | column | more
}
#
# OTHER COMMANDS
#
cmd_extension_or_show () {
cmd_usage
}
cmd_usage () {
case $PROGRAM in
"notes") notes_usage;;
"notebook") notebook_usage;;
esac
}
notes_usage () {
cat << ENDHELP
Standard (?) Unix Notes system
GPG encrypted notes system for BSD and Linux systems
notes init initialise notes system
notes config display config file
notes backup backup NOTESDIR to GPG encrypted tar file
notes newkey email change GPG key
notes help show help
notes version show version
notes find|search|grep find note
notes show|ls|list list notes in current notebook
notes insert|add note_title add a note
notes view|cat note_title view a note
notes import file-path import a text file as a note
notes rename|mv note_title rename a note (prompts for new name)
notes copy|cp note_title copy a note (prompts for new name)
notes delete|remove|rm note_title delete a note
notes edit|ed note_title edit a note in default editor
See notebook(1) or run 'notebook help' for details on managing notebooks
See journal(1) or run 'journal help' for details on the journal/diary feature
ENDHELP
}
notebook_usage () {
cat << ENDHELP
Standard (?) Unix Notes system
GPG encrypted notes system for BSD and Linux systems
notebook help show help
notebook version show version
notebook config show config
notebook list|ls|show list notebooks
notebook default notebook change default notebook
notebook use [notebook] use notebook (no notebook: uses default)
notebook add|insert notebook add notebook
notebook rename|mv notebook rename notebook (prompts for new name)
notebook copy|cp notebook copy notebook (prompts for new name)
notebook delete|remove|rm notebook delete notebook
See notes(1) or run 'notes help' for details on managing notes
See journal(1) or run 'journal help' for details on the journal/diary feature
ENDHELP
}
cmd_version () {
echo "Version $VERSION"
}
cmd_config () {
echo The 'config' file contains:
echo ""
echo -----------------------------------------
echo ""
cat $CONFIGFILE
echo ""
echo -----------------------------------------
echo ""
echo The DEFAULT notebook is `ls -l $DEFAULT_POINTER | cut -d' ' -f9-`
echo The USE notebook is `ls -l $USE_POINTER | cut -d' ' -f9- `
echo The Journal uses the directory $JOURNALDIR
}
cmd_gitlog () {
${GITLOG}
}
cmd_gitstatus () {
${GITSTATUS}
}
cmd_backup () {
get_recipient
echo running tar backup to $BACKUPFILE
tar cv ${NOTESDIR} | gpg -ear ${KEY} ${GPGOPTS} > ${BACKUPFILE}
}
cmd_tree () {
tree -I Journal ${NOTESDIR}
}
cmd_view () {
myoptions="$@"
if [ "$1" = "" ]; then
echo No note specified on command line
exit 1
fi
case $PROGRAM in
"notes") note_view $myoptions;;
"notebook") cmd_usage;;
esac
}
cmd_show () {
myoptions="$@"
case $PROGRAM in
"notes") note_list $myoptions;;
"notebook") notebook_list $myoptions;;
esac
}
cmd_find () {
searchterm="$@"
for file in ${USE_POINTER}/*.asc
do
gpg -d $file 2>/dev/null | grep -H --label ${file} "$searchterm"
done
}
cmd_insert () {
myoptions="$@"
case $PROGRAM in
"notes") note_add $myoptions;;
"notebook") notebook_add $myoptions;;
esac
}
cmd_import () {
myoptions="$@"
case $PROGRAM in
"notes") note_import $myoptions;;
"notebook") cmd_usage;;
esac
}
cmd_generate () {
echo cmd_generate not implemented yet
}
cmd_delete () {
myoptions="$@"
case $PROGRAM in
"notes") note_delete $myoptions;;
"notebook") notebook_delete $myoptions;;
esac
}
cmd_edit () {
myoptions="$@"
case $PROGRAM in
"notes") note_edit $myoptions;;
"notebook") notebook_edit ${myoptions};;
esac
}
cmd_copy_move () {
myoptions="$@"
case $PROGRAM in
"notes") note_rename $myoptions;;
"notebook") notebook_rename ${myoptions};;
esac
}
cmd_git () {
echo git not implemented yet
}
cmd_default () {
nb="$@"
notebook="$NOTESDIR/$nb"
if [ "$nb" = "" ] ;then
echo Default notebook = "`readlink -f $DEFAULT_POINTER`"
return 0
fi
if [ -d "$notebook" ] ; then
unlink "$DEFAULT_POINTER"
ln -sf "$nb" "$DEFAULT_POINTER"
else
echo Cannot set default notebook to $notebook as it does not exist
exit 1
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Switch default notebook to ${notebook}" > /dev/null
fi
}
cmd_use () {
nb="$@"
notebook="$NOTESDIR/$nb"
if [ "$nb" = "" ] ;then
defaultnbval="`readlink -f $DEFAULT_POINTER`"
defaultnb="`basename $DEFAULT_POINTER`"
echo no notebook specified using default notebook
unlink "$USE_POINTER"
ln -s "`basename $defaultnbval`" "$USE_POINTER"
return 0
fi
if [ -d "$notebook" ] ; then
unlink "$USE_POINTER"
ln -sf "$nb" "$USE_POINTER"
else
echo Cannot use $notebook as $nb does not exist
exit 1
fi
if [ "$USEGIT" = "y" ]; then
${GITADD} ${NOTESDIR} > /dev/null
${GITCOMMIT} "Switch notebook to ${notebook}" > /dev/null
fi
}
cmd_newkey () {
mynewkey="$1"
if [ "$mynewkey" = "" ]; then
echo No new key supplied
echo There are the following private keys on your keyring
gpg --list-secret-keys --with-colons --keyid-format short | grep sec | cut -d':' -f 5
exit 1
fi
get_recipient
get_gpg_keyid $mynewkey
# now recrypt files
find ~/.notes -name \*.asc | sed s/.asc// | \
while read filen ;
do
echo $filen;
gpg -o "${filen}" --yes -d "${filen}.asc"
gpg -r ${mynewkey} --yes -ea "${filen}" && ${SHREDCMD} "${filen}"
done
# replace key in config file
sed -i s/^KEY.*$/KEY\\t${mynewkey}/ ${CONFIGFILE}
}
cmd_licence () {
${PAGER} <<EOF
BSD 3-Clause License
Copyright (c) 2021, Standard-Unix-Notes
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EOF
}
#########################
# #
# MAIN PROGRAM #
# #
#########################
PROGRAM="`basename ${0##*/}`"
COMMAND="$1"
case "$1" in
init) shift; cmd_init "$@" ;;
log) shift; cmd_gitlog "$@" ;;
status) shift; cmd_gitstatus "$@" ;;
config) shift; cmd_config "$@" ;;
backup) shift; cmd_backup ;;
tree) shift; cmd_tree ;;
licence|license) shift; cmd_licence "$@" ;;
default) shift; cmd_default "$@" ;;
use) shift; cmd_use "$@" ;;
newkey) shift; cmd_newkey "$@" ;;
help|--help) shift; cmd_usage "$@" ;;
version|--version) shift; cmd_version "$@" ;;
show|ls|list) shift; cmd_show "$@" ;;
view|cat) shift; cmd_view "$@" ;;
find|search|grep) shift; cmd_find "$@" ;;
insert|add) shift; cmd_insert "$@" ;;
import) shift; cmd_import "$@" ;;
edit|ed) shift; cmd_edit "$@" ;;
generate) shift; cmd_generate "$@" ;;
delete|rm|remove) shift; cmd_delete "$@" ;;
rename|mv) shift; cmd_copy_move "mv" "$@" ;;
copy|cp) shift; cmd_copy_move "cp" "$@" ;;
git) shift; cmd_git "$@" ;;
*) cmd_extension_or_show "$@" ;;
esac