forked from rmm5t/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_completion
57 lines (49 loc) · 1.52 KB
/
bash_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
54
55
56
57
# http://onrails.org/articles/2006/11/17/rake-command-completion-using-rake
if [ -f ~/bin/rake_completion ]; then
. ~/bin/rake_completion
fi
# Completion for custom git aliases
# Borrowed and modified from:
# https://github.com/bronson/dotfiles/blob/731bfd95/.bashrc#L81
complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \
|| complete -o default -o nospace -F _git g
__define_git_completion () {
eval "
_git_$2_shortcut () {
COMP_LINE=\"git $2\${COMP_LINE#$1}\"
let COMP_POINT+=$((4+${#2}-${#1}))
COMP_WORDS=(git $2 \"\${COMP_WORDS[@]:1}\")
let COMP_CWORD+=1
local cur words cword prev
_get_comp_words_by_ref -n =: cur words cword prev
_git_$2
}
"
}
__git_shortcut () {
type _git_$2_shortcut &>/dev/null || __define_git_completion $1 $2
# alias $1="git $2 $3"
# complete -o default -o nospace -F _git_$2_shortcut $1
complete -o bashdefault -o default -o nospace -F _git_$2_shortcut $1 2>/dev/null \
|| complete -o default -o nospace -F _git_$2_shortcut $1
}
__git_shortcut gco checkout
__git_shortcut gc commit
__git_shortcut gl pull
__git_shortcut glr pull
__git_shortcut gp push
__git_shortcut gs status
__git_shortcut gb branch
__git_shortcut gu branch
__git_shortcut gd diff
__git_shortcut gcp cherry-pick
__git_shortcut gr remote
if type kubectl &> /dev/null; then
source <(kubectl completion bash)
fi
if type pip3 &> /dev/null; then
eval `python3 -m pip completion --bash`
fi
if [ -f ~/taros-complete.sh ]; then
. ~/taros-complete.sh
fi