summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-10-17 15:15:40 -0500
committerJohn Southworth <john.southworth@vyatta.com>2011-10-17 15:49:51 -0500
commit4fdd247db6af6177a1ac66eaa4a01c1541e7b69a (patch)
tree729726aa47fe2744c557d4777184cf58de401d97 /functions
parentc257bf118f53044112c458aecc9b2c9ebb494086 (diff)
downloadvyatta-op-4fdd247db6af6177a1ac66eaa4a01c1541e7b69a.tar.gz
vyatta-op-4fdd247db6af6177a1ac66eaa4a01c1541e7b69a.zip
Allow completions using normal dirctory paths as well as a shortcut to running:// in file name completions
Diffstat (limited to 'functions')
-rw-r--r--functions/interpreter/vyatta-image-complete22
1 files changed, 17 insertions, 5 deletions
diff --git a/functions/interpreter/vyatta-image-complete b/functions/interpreter/vyatta-image-complete
index d9dc240..130fa13 100644
--- a/functions/interpreter/vyatta-image-complete
+++ b/functions/interpreter/vyatta-image-complete
@@ -21,13 +21,17 @@
_vyatta_image_is_file()
{
local cur=$1
- cur=${cur/:/}
- topdir=${cur%%/*}
- cur=${cur#$topdir/}
+ if ! [[ ${cur:0:1} =~ "/" ]]; then
+ cur=${cur/:/}
+ topdir=${cur%%/*}
+ cur=${cur#$topdir/}
+ fi
if [[ $topdir == "running" ]]; then
cur="/${cur}"
elif [[ $topdir == "disk-install" ]]; then
cur="/live/image/${cur}"
+ elif [[ ${cur:0:1} =~ "/" ]]; then
+ cur=${cur}
else
cur="/live/image/boot/${topdir}/live-rw/${cur}"
fi
@@ -57,6 +61,14 @@ _vyatta_image_path_complete()
_vyatta_op_completions=( "${cur} " )
return 0;
fi
+ if [[ ${cur:0:1} =~ "/" ]]; then
+ reply=( $(compgen -f ${cur}) )
+ for ((i=0; i < ${#reply[@]}; i++)); do
+ [[ -d ${reply[i]} ]] && reply[i]="${reply[i]}"/
+ done
+ _vyatta_op_completions=( "${reply[@]}" )
+ return
+ fi
if [[ ${cur} == "" ]]; then
reply=( $(compgen -d /live/image/boot/ | grep -v grub) )
for i in `seq 0 $[${#reply[@]}-1]`; do
@@ -85,7 +97,7 @@ _vyatta_image_path_complete()
else
cur="/live/image/boot/${cur}"
fi
- reply=( $(compgen -f ${cur}) )
+ reply=( $(compgen -f ${cur} | grep -v grub) )
for i in `seq 0 $[${#reply[@]}-1]`; do
file=${reply[$i]}
if [[ $isrunningimg == "running" ]];then
@@ -129,7 +141,7 @@ _vyatta_image_path_complete()
if [[ $topdir == "running" ]]; then
reply[$i]=${file/#\//"$topdir://"}
elif [[ $topdir == "disk-install" ]]; then
- reply[$i]=${file/#\/live\/image\//$"$topdir://"}
+ reply[$i]=${file/#\/live\/image\//"$topdir://"}
else
reply[$i]=${file/#\/live\/image\/boot\/$topdir/"$topdir://"}
reply[$i]=${reply[$i]/\/live-rw\/}