-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash-completions
59 lines (52 loc) · 1.97 KB
/
.bash-completions
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
GIT_COMPLETE_REVLIST_MAX=1500
# Better to use __git_complete from
# curl -O https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
# But let's leave this here for the times that may be unavailable
if test -r "$HOME/.config/$USER/git-completion.bash"; then
source "$HOME/.config/$USER/git-completion.bash"
# Sigh. git-completion from that site is broken. Apply:
# diff --git a/git-completion.bash b/git-completion.bash
# index 4262236..7a25df6 100644
# --- a/git-completion.bash
# +++ b/git-completion.bash
# @@ -3778,7 +3778,7 @@ __git_main ()
# then
# __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
# else
# - local list_cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config
# + local list_cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config,main
#
# if test "${GIT_COMPLETION_SHOW_ALL_COMMANDS-}" = "1"
# then
#
__git_complete g __git_main
__git_complete git __git_main
else
_git_complete() {
local cur_word="${COMP_WORDS[ COMP_CWORD ]}"
local dir=$(dirname $cur_word 2> /dev/null)
local repl
case "$dir" in
(.) ;;
(/) repl=/;;
(*) repl="${dir}/";;
esac
if test "$COMP_CWORD" = 1; then
list=$( git help -a | awk '/^ /{print $1}' )
else
list=$( git for-each-ref refs --format '%(refname:short)'
command ls -F -1 "$dir" 2> /dev/null \
| sed -e "s@^@$repl@"
git rev-list --all | sed ${GIT_COMPLETE_REVLIST_MAX}q
)
fi
COMPREPLY=( $(compgen -W "${list}" -- ${cur_word}) )
}
complete -o bashdefault -o default -o nospace -F _git_complete git
fi
_y_complete() {
cur_word="${COMP_WORDS[ COMP_CWORD ]}"
list=$( git for-each-ref refs --format '%(refname:short)' 2> /dev/null )
COMPREPLY=( $(compgen -W "${list}" -- ${cur_word}) )
}
complete -o bashdefault -o default -o nospace -F _y_complete y