summaryrefslogtreecommitdiffstats
path: root/scripts/bash_completion
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2012-10-28 14:43:35 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2012-10-28 15:48:04 +0100
commit4a35b0641f9236a40abcb6b6540a420b819cb012 (patch)
treea52d2ce8468ee9ea8279d5e6c07c89d12d1bdaa5 /scripts/bash_completion
parentf0bf8194ce3c5df564bea87129d634d2a9a2cc7a (diff)
downloadptxdist-4a35b0641f9236a40abcb6b6540a420b819cb012.tar.gz
ptxdist-4a35b0641f9236a40abcb6b6540a420b819cb012.tar.xz
bash_completion: generate and cache commands
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts/bash_completion')
-rw-r--r--scripts/bash_completion9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/bash_completion b/scripts/bash_completion
index 7be15df14..627898f3b 100644
--- a/scripts/bash_completion
+++ b/scripts/bash_completion
@@ -8,6 +8,7 @@
if have ptxdist; then
declare -a _ptxdist_completion_opts
+declare -a _ptxdist_completion_cmds
declare -a _ptxdist_completion_newpkg
_ptxdist_completion()
{
@@ -24,7 +25,9 @@ _ptxdist_completion()
if [ ${#_ptxdist_completion_opts[@]} -eq 0 ]; then
_ptxdist_completion_opts=( $(${_ptxdist_cmd} | sed -n 's,.*\(--[a-z0-9-]*=\?\).*,\1,p') )
fi
- cmds=' allmodconfig allnoconfig allyesconfig autobuild boardsetup clean clone collection compile distclean drop export_src extract get go image images install kernelconfig menu menuconfig migrate newpackage nfsroot oldconfig platform platformconfig prepare print projects ptxdist select setup tags targetinstall test toolchain u_boot_config version'
+ if [ ${#_ptxdist_completion_cmds[@]} -eq 0 ]; then
+ _ptxdist_completion_cmds=( $(${_ptxdist_cmd} | sed -n 's/^ \([a-z][^ \t]*\)[ \t].*/\1/p' | sort -u | grep -v ptxdist) )
+ fi
words=()
last=
@@ -64,7 +67,7 @@ _ptxdist_completion()
for (( i=1 ; i<${cword}; i++ )); do
local tmp="${words[i]}"
- if grep -q "\<${tmp}\>" <<< "${cmds}"; then
+ if grep -q "\<${tmp}\>" <<< "${_ptxdist_completion_cmds[*]}"; then
# the command that is currently completed
cmd="${tmp}"
continue
@@ -89,7 +92,7 @@ _ptxdist_completion()
case ${cmd} in
"")
# if no commands were given, complete on commands themselves
- COMPREPLY=( $( compgen -W "${_ptxdist_completion_opts[*]} ${cmds} help" -- $cur ) )
+ COMPREPLY=( $( compgen -W "${_ptxdist_completion_opts[*]} ${_ptxdist_completion_cmds[*]} help" -- $cur ) )
;;
menuconfig)
COMPREPLY=( $( compgen -W "${_ptxdist_completion_opts[*]} kernel platform barebox board collection user" -- $cur) )