-
Notifications
You must be signed in to change notification settings - Fork 1
/
git-mu-completion.bash
76 lines (70 loc) · 1.74 KB
/
git-mu-completion.bash
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
# See https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# bash completion support for git-mu
#
# Source this file in one of your shell startup scripts (e.g. .bashrc):
#
# . ~/.dotfiles/git-mu-completion.bash
#
# Git completion is required.
#
_git_mu() {
# Disable default bash completion (current directory file names, etc.)
compopt +o bashdefault +o default 2>/dev/null
local mu_cmds="
group
list
register
sh
st
"
local git_cmds="
add
branch
checkout clean cleargui commit config
describe diff difftool
fetch fsck
gc grep
help
log
maintenance merge mv
prune pull push
reflog remote reset restore rm
shortlog show show-branch stage stash status submodule switch
tag
whatchanged worktree
"
local aliases="
ss sp
fast-forward ff
update
sup
graph context-graph cg
uncommit prev-commit recommit
force-push fp
pushall fpushall
mr
gca
gone
forget
branches
contains
mb nmb stmb stnmb rnob rrnob
transfer-remote
recurse
"
__gitcomp "${mu_cmds} ${git_cmds} ${aliases}"
}
# Load git completion if not loaded yet and available at usual paths
if ! declare -f __git_complete &>/dev/null; then
if [[ -f "${HOME}/.local/share/bash-completion/completions/git" ]]; then
. "${HOME}/.local/share/bash-completion/completions/git"
elif [[ -f "/usr/share/bash-completion/completions/git" ]]; then
. "/usr/share/bash-completion/completions/git"
fi
fi
# Add completion for aliases
if declare -f __git_complete > /dev/null; then
for a in $(alias -p | grep "git[- ]mu" | cut -d' ' -f2 | cut -d= -f1); do
__git_complete "$a" _git_mu
done
fi