-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompletion
53 lines (41 loc) · 1.47 KB
/
completion
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
#!/bin/sh
# Gittie completion
_gittie()
{
local cur prev commands
COMPREPLY=()
GIT_REPO=$(git rev-parse --is-inside-work-tree 2>/dev/null)
first="${COMP_WORDS[1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="c a p s ch m ms fp rb rba rbc r rh rs"
if [[ ${first} == "rb" && ${GIT_REPO} ]]; then
COMPREPLY=( $(compgen -W "$(git for-each-ref --format="%(refname:short)")" -- ${cur}) )
return 0
fi
if [[ ${first} == "fp" && ${GIT_REPO} ]]; then
COMPREPLY=( $(compgen -W "$(git for-each-ref --format="%(refname:short)")" -- ${cur}) )
return 0
fi
if [[ ${first} == "m" && ${GIT_REPO} ]]; then
COMPREPLY=( $(compgen -W "$(git for-each-ref --format="%(refname:short)")" -- ${cur}) )
return 0
fi
if [[ ${first} == "ms" && ${GIT_REPO} ]]; then
COMPREPLY=( $(compgen -W "$(git for-each-ref --format="%(refname:short)")" -- ${cur}) )
return 0
fi
if [[ ${first} == "p" && ${GIT_REPO} ]]; then
COMPREPLY=( $(compgen -W "$(git for-each-ref --format="%(refname:short)")" -- ${cur}) )
return 0
fi
if [[ ${first} == "ch" && ${GIT_REPO} ]]; then
COMPREPLY=( $(compgen -W "$(git for-each-ref --format="%(refname:short)")" -- ${cur}) )
return 0
fi
if [[ -z "${cur}" && ${COMP_CWORD} == 1 ]]; then
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
return 0
fi
}
complete -F _gittie gittie