diff options
Diffstat (limited to 'nagscripts.bash')
-rw-r--r-- | nagscripts.bash | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/nagscripts.bash b/nagscripts.bash index 5f95575..11ec4fb 100644 --- a/nagscripts.bash +++ b/nagscripts.bash @@ -1,16 +1,27 @@ -# Completion tools for Nagscripts suite -_nagscripts_objects() { - local object +# Source this file to get host and service completion for the Nagscript tools. +_nagios_objects() { + local word=${COMP_WORDS[COMP_CWORD]} + declare -a cmd + case $word in + */*) + cmd=(nagios-data-search -s ^"${word#*/}") + ;; + *) + compopt -o nospace + cmd=(nagios-data-search ^"$word") + ;; + esac while read -r object ; do - [[ $object == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue - COMPREPLY[${#COMPREPLY[@]}]=$object - done < <(cat <(nagios-data-search .) <(nagios-data-search -s .)) - return + case $object in + "$word"*) COMPREPLY[${#COMPREPLY[@]}]=$object ;; + esac + done < <("${cmd[@]}") } -complete -F _nagscripts_objects -o default \ - nagios-acknowledge \ - nagios-data-search \ +complete -F _nagios_objects -o default \ + nagios-acknowledge \ + nagios-clear \ nagios-downstream-list \ - nagios-downtime \ - nagios-exists \ + nagios-data-search \ + nagios-downtime \ + nagios-exists \ nagios-force-check |