-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitsick.sh
31 lines (27 loc) · 986 Bytes
/
gitsick.sh
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
# Source this file from your ~/.bashrc to enable Bash completions for gitsick.
_gitsick_complete() {
# first argument is a gitsick repo otherwise delegate to git's contrib completion
if test "$COMP_CWORD" = 1
then
GITSICK_DIR="$(git config --global gitsick.dir || true)"
if [ -z "$GITSICK_DIR" ]; then
GITSICK_DIR="$HOME/.gitsick"
fi
NAMES="$(command ls "$GITSICK_DIR" | command sed 's/\.git$//') init clone"
COMPREPLY=( $(compgen -W "$NAMES" -- ${COMP_WORDS[COMP_CWORD]}) )
if test -n "$COMPREPLY"
then
COMPREPLY="$COMPREPLY "
fi
return
fi
if test "${COMP_WORDS[1]}" = "init" -o "${COMP_WORDS[1]}" = "clone"
then
return
fi
((COMP_CWORD--))
COMP_WORDS=("${COMP_WORDS[@]:1}")
_git
}
complete -o bashdefault -o default -o nospace -F _gitsick_complete gitsick 2>/dev/null \
|| complete -o default -o nospace -F _gitsick_complete gitsick