-
Notifications
You must be signed in to change notification settings - Fork 0
/
_branch-notes
64 lines (58 loc) · 2.5 KB
/
_branch-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
#compdef _branch-notes branch-notes
#
# branch-notes zsh completion
# vim: filetype=zsh
function _branch-notes {
local line
_arguments -C \
"--help[Show help]" \
"1: :(open list archive)" \
"*::arg:->args"
case $line[1] in
open)
_branch-notes_open
;;
list)
_branch-notes_list
;;
archive)
_branch-notes_archive
;;
esac
}
function _branch-notes_open {
_arguments \
":branch name:($(find "$NOTES_DIR/" -maxdepth 2 \
\( -type f -or -type l \) -print \
-name "*.txt" | awk -F/ '{print $NF}' | \
cut -d "." -f 1))" \
"--toplevel[Specify toplevel directory]:toplevel:($(find "$NOTES_DIR/" \
-maxdepth 1 -type d -print \
-name "[^\.]\*" | \
awk -F/ '{print $NF}' | \
sed -e 's/[[:space:]]/\\\ /g'))" \
"--editor[Specify the editor to open the note with]:editor:()" \
"--help[Show help]"
}
function _branch-notes_list {
_arguments \
"--toplevel[Specify toplevel directory]:toplevel:($(find "$NOTES_DIR/" \
-maxdepth 1 -type d -print \
-name "[^\.]\*" | \
awk -F/ '{print $NF}' | \
sed -e 's/[[:space:]]/\\\ /g'))" \
"--help[Show help]"
}
function _branch-notes_archive {
_arguments \
":branch name:($(find "$NOTES_DIR/" -maxdepth 2 \
\( -type f -or -type l \) -print \
-name "*.txt" | awk -F/ '{print $NF}' | \
cut -d "." -f 1))" \
"--toplevel[Specify toplevel directory]:toplevel:($(find "$NOTES_DIR/" \
-maxdepth 1 -type d -print \
-name "[^\.]\*" | \
awk -F/ '{print $NF}' | \
sed -e 's/[[:space:]]/\\\ /g'))" \
"--help[Show help]"
}