-
Notifications
You must be signed in to change notification settings - Fork 0
/
tig-completion.bash
executable file
·89 lines (84 loc) · 2.24 KB
/
tig-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
77
78
79
80
81
82
83
84
85
86
87
88
89
# bash/zsh completion for tig
#
# Copyright (C) 2019 Roland Hieber, Pengutronix
# Copyright (C) 2007-2010 Jonas fonseca
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This completion builds upon the git completion (>= git 1.17.11),
# which most tig users should already have available at this point.
# To use these routines:
#
# 1) Copy this file to somewhere (e.g. ~/.bash_completion.d/tig).
#
# 2) Add the following line to your .bashrc:
#
# source ~/.bash_completion.d/tig
#
# Note that most Linux distributions source everything in
# ~/.bash_completion.d/ automatically at bash startup, so you
# have to source this script manually only in shells that were
# already running before.
#
# 3) You may want to make sure the git executable is available
# in your PATH before this script is sourced, as some caching
# is performed while the script loads. If git isn't found
# at source time then all lookups will be done on demand,
# which may be slightly slower.
__tig_options="
-v --version
-h --help
-C
"
__tig_commands="
blame
grep
log
reflog
refs
stash
status
show
"
__tig_main () {
# parse already existing parameters
local i c=1 command
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
--) command="log"; break;;
-C) return;;
-*) ;;
*) command="$i"; break ;;
esac
c=$((++c))
done
# commands
case "$command" in
refs|status|stash)
__gitcomp "$__tig_options"
;;
reflog)
__git_complete_command log
;;
"")
__git_complete_command log
__gitcomp "$__tig_options $__tig_commands"
;;
*)
__git_complete_command $command
;;
esac
}
# we use internal git-completion functions, so wrap _tig for all necessary
# variables (like cword and prev) to be defined
__git_complete tig __tig_main
# The following are necessary only for Cygwin, and only are needed
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
__git_complete tig.exe __tig_main
fi