-
Notifications
You must be signed in to change notification settings - Fork 0
/
_cb
32 lines (24 loc) · 773 Bytes
/
_cb
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
#compdef cb
zstyle ':completion::complete:cb:*:descriptions' format '%B%d%b'
zstyle ':completion::complete:cb:*:workspaces_list' group-name workspaces_list
zstyle ':completion::complete:cb::' list-grouped
function _cb() {
local ROSWS_CONFIG=${ROSWS_CONFIG:-$HOME/.config/ros2-env/workspaces}
local ret=1
local -a workspaces_list
workspaces_list=( ${(f)"$(< $ROSWS_CONFIG)"} )
# Format output to be a bit prettier
for ((i = 1; i <= $#workspaces_list; i++))
do
workspaces_list[$i]=$(sed 's/:/ --> /2g' <<<"$workspaces_list[$i]")
done
_arguments -C \
'1: :->first_arg' && ret=0
local target=$words[1]
if [[ $state == first_arg ]]
then
_describe -t workspaces_list "Workspaces" workspaces_list && ret=0
fi
return $ret
}
_cb "$@"