forked from rebase-helper/rebase-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebase-helper.bash.in
53 lines (44 loc) · 1.62 KB
/
rebase-helper.bash.in
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
# Bash completion for rebase-helper
# Copyright (C) 2013-2014 Red Hat, Inc.
#
# 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 program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Author: Tomas Hozza <thozza@redhat.com>
shopt -s extglob
_rebase-helper()
{
local rh_options=@RH_OPTIONS@
local rh_choices=@RH_CHOICES@
local rh_extensions=@RH_EXTENSIONS@
local cur prev idx
_get_comp_words_by_ref -n = cur prev
_split_longopt
# complete choices, if the last word is known option which has some
for idx in "${!rh_options[@]}"; do
if [[ "${rh_options[idx]}" == *"${prev}"* ]]; then
if [[ -n "${rh_choices[idx]}" ]]; then
COMPREPLY=( $(compgen -W "${rh_choices[idx]}" -- "${cur}") )
return 0
fi
break
fi
done
# complete options
COMPREPLY=( $(compgen -W "$(echo "${rh_options[@]}")" -- "${cur}") )
# add recognized archive extensions
_filedir "${rh_extensions}"
return 0
}
complete -F _rebase-helper rebase-helper