Closed OndrejHome closed 6 years ago
Based on PR #34 add and test bash completion with scp and keydist commands.
scp
keydist
diff --git a/fast-vm.bash_completion b/fast-vm.bash_completion index defd6f8..48a542d 100644 --- a/fast-vm.bash_completion +++ b/fast-vm.bash_completion @@ -94,6 +94,21 @@ _fast-vm() return 0 fi + if [ "$cword" -eq 3 ] && [ ${COMP_WORDS[1]} == "scp" ]; then + COMPREPLY=( $( compgen -W "vm:" -f -- "$cur" ) ) + return 0 + fi + if [ "$cword" -eq 4 ] && [ ${COMP_WORDS[1]} == "scp" ]; then + # source path did /not/ contain "vm:", so prompt only that + COMPREPLY=( $( compgen -W "vm:" ) ) + return 0 + fi + if [ "$cword" -ge 5 ] && [ ${COMP_WORDS[1]} == "scp" ]; then + # source path /did/ contain "vm:", so exclude it from destination + COMPREPLY=( $( compgen -f -- "$cur" ) ) + return 0 + fi + case $prev in import_image|import_custom_image|import_profile) return 0 @@ -122,7 +137,7 @@ _fast-vm() COMPREPLY=( $( compgen -W "all active inactive" -- "$cur" ) ) return 0 ;; - start|stop|delete|console|ssh|info|resize) + start|stop|delete|console|keydist|scp|ssh|info|resize) local vm_numbers case $prev in start|resize) @@ -131,7 +146,7 @@ _fast-vm() delete|edit_note|info) vm_numbers=$(fast-vm list all short) ;; - console|ssh|stop) + console|keydist|scp|ssh|stop) vm_numbers=$(fast-vm list active short) ;; esac @@ -142,7 +157,7 @@ _fast-vm() $split && return 0 if [ "$cword" -lt 2 ]; then - COMPREPLY=( $( compgen -W 'import_image import_custom_image export_image remove_image resize_image import_profile remove_profile edit_note list_images list_profiles create start stop delete resize console ssh list info' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'import_image import_custom_image export_image remove_image resize_image import_profile remove_profile edit_note keydist list_images list_profiles create start stop delete resize console scp ssh list info' -- "$cur" ) ) return 0 fi
released in 1.4
Based on PR #34 add and test bash completion with
scp
andkeydist
commands.