diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-10-17 15:15:40 -0500 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-10-17 15:15:40 -0500 |
commit | 24590debf0c05d7f63aab62c8ddf7c22e01ac075 (patch) | |
tree | 87a216a600e6e48547136ab93d4bc8a0293d940b /functions | |
parent | db23175f41f01367889e5df7b7a2d60e17079efe (diff) | |
download | vyatta-op-24590debf0c05d7f63aab62c8ddf7c22e01ac075.tar.gz vyatta-op-24590debf0c05d7f63aab62c8ddf7c22e01ac075.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-complete | 22 |
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\/} |