Add __fish_print_VBox_vms function

Improve __fish_print_VBox_vms
This commit is contained in:
Clément Martinez 2016-12-02 15:45:57 +01:00 committed by Fabian Homborg
parent 6ab97227de
commit 291a28e79c
2 changed files with 31 additions and 2 deletions

View File

@ -3,9 +3,9 @@ function __fish_print_pygmentize
while set -q lines[2]
set -l names (string split ", " $lines[1])
for name in $names
for name in $names
printf '%s\t%s\n' $name $lines[2]
end
end
set -e lines[1]
set -e lines[1]

View File

@ -0,0 +1,29 @@
function __fish_print_VBox_vms
set -l print_names true
set -l print_uuids true
if contains -- nouuids $argv
set print_uuids false
end
if contains -- nonames $argv
set print_names false
end
# `VBoxManage list vms` output example:
# "Machine Name" {222537b0-1ea1-454a-abf0-ed0d6c3c6346}
# "Another Machine" {332537b4-1ea1-454a-abf0-ed1d6c3c2347}
set -l lines (VBoxManage list vms | string match -r '"(.*)" {(.*)}')
while set -q lines[3]
if test $print_names = true
printf '%s\tVirtual machine\n' $lines[2]
end
if test $print_uuids = true
printf '%s\t%s virtual machine\n' $lines[3] $lines[2]
end
set -e lines[1..3]
end
end