Skip to content

Commit

Permalink
Merge pull request #308 from etown/dev
Browse files Browse the repository at this point in the history
completion suggestions for chisel names
  • Loading branch information
gianlucaborello committed Feb 9, 2015
2 parents 6598c30 + 1d3921e commit 62bbc44
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions scripts/completions/bash/sysdig
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,37 @@ _sysdig_complete()
local prev=${COMP_WORDS[COMP_CWORD-1]}

case "$prev" in
-r)
COMPREPLY=()
-c|--chisel)
local chisels=""
local detail="Use the -i flag to get detailed information about a specific chisel"
while IFS= read -r line
do
if [[ $line =~ "---" ]]; then
# skip lines such as
# -----------------
continue;
elif [[ -z "$line" ]]; then
# empty lines reset the category
continue;
elif [[ $line =~ "Category" ]]; then
# category
continue;
elif [[ $line =~ $detail ]]; then
# detail instructions
continue;
fi

local chisel=${line%% *}

if [[ -z "$chisel" ]]; then
# empty lines from description
continue;
fi

chisels="$chisels $chisel"

done < <(sysdig -cl)
COMPREPLY=( $( compgen -W "$chisels" -- $cur ) )
return 0
;;

Expand Down

0 comments on commit 62bbc44

Please sign in to comment.