summaryrefslogtreecommitdiff
path: root/etc/bash_completion.d/20vyatta-cfg
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2007-12-12 14:09:16 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2007-12-12 14:09:16 -0800
commit96b548691d857e331ebcb0313ff94bd40127b795 (patch)
treed043c479aaf60ca1e99cbe4b423f5ed528624289 /etc/bash_completion.d/20vyatta-cfg
parent42aff76b3686beb463a77f3dabd4c5beed961120 (diff)
downloadvyatta-cfg-96b548691d857e331ebcb0313ff94bd40127b795.tar.gz
vyatta-cfg-96b548691d857e331ebcb0313ff94bd40127b795.zip
add completion/help for pipe commands
Diffstat (limited to 'etc/bash_completion.d/20vyatta-cfg')
-rw-r--r--etc/bash_completion.d/20vyatta-cfg32
1 files changed, 19 insertions, 13 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg
index dc05cf1..78f2e0a 100644
--- a/etc/bash_completion.d/20vyatta-cfg
+++ b/etc/bash_completion.d/20vyatta-cfg
@@ -647,6 +647,17 @@ ENDCOMMENT
vyatta_help_text="\\nNo help text available"
}
+generate_pipe_help ()
+{
+ local -a hcomps=( "${_vyatta_pipe_completions[@]}" \
+ "${_vyatta_pipe_noncompletions[@]}" )
+ local -a hstrs=()
+ for comp in "${hcomps[@]}"; do
+ hstrs+=("$(_vyatta_pipe_help "$comp")")
+ done
+ generate_help_text hcomps hstrs
+}
+
vyatta_config_complete ()
{
local restore_shopts=$( shopt -p extglob nullglob | tr \\n \; )
@@ -660,6 +671,14 @@ vyatta_config_complete ()
vyatta_do_help=0
fi
+ # handle pipe
+ if _vyatta_pipe_completion "${COMP_WORDS[@]}"; then
+ generate_pipe_help
+ vyatta_completions=( "${_vyatta_pipe_completions[@]}" )
+ vyatta_do_complete
+ return
+ fi
+
if (( ${#COMP_WORDS[@]} < 2 )); then
declare -a hitems=( "commit" \
"delete" \
@@ -707,19 +726,6 @@ vyatta_config_complete ()
(( num_comp -= 1 ))
fi
- # handle pipe
- if [ "${COMP_WORDS[$num_comp]}" == "|" ]; then
- declare -a hitems=( "more" \
- )
- declare -a hstrs=( \
- "Paginate the output" \
- )
- generate_help_text hitems hstrs
- vyatta_completions=( "${hitems[@]}" )
- vyatta_do_complete
- return
- fi
-
(( last_idx = num_comp - 1 ))
comp_words=( ${COMP_WORDS[@]:1:$num_comp} )