Skip to content

Commit c95fc40

Browse files
committed
Reflect completion.bash
1 parent 1797703 commit c95fc40

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

lib/completion.bash

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,35 @@
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5-
6-
# COMPREPLY: array holds the completion results that gets displayed after
7-
# pressing [TAB][TAB]
8-
#
9-
# COMP_WORDS: array of words that is typed on the command line
10-
#
11-
# COMP_CWORD: index for the COMP_WORDS array and using this different position
12-
# words on command line can be accessed.
13-
#
14-
# compgen : -W holds the possible completions and the respective argument get
15-
# chosen based on the $current_arg.
16-
#
17-
# By convention, the function name starts with an underscore.
18-
# .bash_completion
19-
# source ./lib/completion.bash
20-
21-
225
#
236
# dev completion
7+
# By convention, the function name starts with an underscore.
248
#
259
_dev_init_completion() {
2610
# Pointer to current completion word.
2711
# By convention, it's named "cur" but this isn't strictly necessary.
28-
local arr cur prev opts
12+
local arr cur opts
2913

14+
# COMPREPLY: array holds the completion results that gets displayed after
15+
# pressing [TAB][TAB]
3016
COMPREPLY=() # Array variable storing the possible completions.
17+
18+
# COMP_WORDS: array of words that is typed on the command line
19+
#
20+
# COMP_CWORD: index for the COMP_WORDS array and using this different position
21+
# words on command line can be accessed.
3122
cur=${COMP_WORDS[COMP_CWORD]}
32-
prev=${COMP_WORDS[COMP_CWORD-1]}
3323

3424
if [ "${cur:0:1}" == "-" ]; then
3525
opts=$(dev ":options" 2>/dev/null) #
3626
else
37-
arr=(${COMP_WORDS[@]})
38-
unset arr[COMP_CWORD]
27+
arr=(${COMP_WORDS[@]}) && unset arr[COMP_CWORD]
3928
[ "${arr[0]}" == "dev" ] && unset arr[0]
40-
# echo "cur:$cur" >&2
41-
# echo "arr:${arr[@]:1}" >&2
42-
opts=$(dev ":completion" ":$cur" "${arr[@]}" 2>/dev/null) #
29+
opts=$(dev ":completion" ":$cur" "${arr[@]}" 2>/dev/null)
4330
fi
4431

32+
# compgen : -W holds the possible completions and the respective argument get
33+
# chosen based on the $current_arg.
4534
COMPREPLY=( $(compgen -W "$opts" -- "$cur" ) );
4635
}
4736

0 commit comments

Comments
 (0)