mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 12:04:39 +08:00
Add __fish_print_VBox_vms function
Improve __fish_print_VBox_vms
This commit is contained in:
parent
6ab97227de
commit
291a28e79c
|
@ -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]
|
||||
|
|
29
share/functions/__fish_print_VBox_vms.fish
Normal file
29
share/functions/__fish_print_VBox_vms.fish
Normal 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
|
Loading…
Reference in New Issue
Block a user