mirror of
https://github.com/oh-my-fish/theme-bobthefish.git
synced 2024-10-27 20:34:23 +00:00
Speed up Vagrant status code by 10-15x.
(Excluding whatever time is spent getting the status from the provider, of course. Can't do much with that) See #56
This commit is contained in:
parent
ca7a3ecaa2
commit
8898658a9a
@ -242,43 +242,24 @@ end
|
|||||||
|
|
||||||
function __bobthefish_prompt_vagrant -S -d 'Display Vagrant status'
|
function __bobthefish_prompt_vagrant -S -d 'Display Vagrant status'
|
||||||
[ "$theme_display_vagrant" = 'yes' -a -f Vagrantfile ]; or return
|
[ "$theme_display_vagrant" = 'yes' -a -f Vagrantfile ]; or return
|
||||||
for machine in (__bobthefish_vagrant_machines)
|
|
||||||
set -l provider (__bobthefish_vagrant_provider $machine)
|
# .vagrant/machines/$machine/$provider/id
|
||||||
set -l id (__bobthefish_vagrant_id $machine $provider)
|
for file in .vagrant/machines/*/*/id
|
||||||
|
read -l id <$file
|
||||||
|
|
||||||
if [ ! -z "$id" ]
|
if [ ! -z "$id" ]
|
||||||
switch "$provider"
|
switch "$file"
|
||||||
case 'virtualbox'
|
case '*/virtualbox/id'
|
||||||
__bobthefish_prompt_vagrant_vbox $id
|
__bobthefish_prompt_vagrant_vbox $id
|
||||||
case 'vmware_fusion'
|
case '*/vmware_fusion/id'
|
||||||
__bobthefish_prompt_vagrant_vmware $id
|
__bobthefish_prompt_vagrant_vmware $id
|
||||||
case 'parallels'
|
case '*/parallels/id'
|
||||||
__bobthefish_prompt_vagrant_parallels $id
|
__bobthefish_prompt_vagrant_parallels $id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function __bobthefish_vagrant_machines -S -d 'List all Vagrant machines'
|
|
||||||
for machine in .vagrant/machines/*
|
|
||||||
echo $machine | command sed -e 's/.*\/\(\w*\)/\1/'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function __bobthefish_vagrant_provider -S -a machine -d 'Get Vagrant provider for <machine>'
|
|
||||||
for provider in .vagrant/machines/$machine/*
|
|
||||||
if [ -e $provider/id ]
|
|
||||||
echo $provider/id | command sed -ne 's/.vagrant\/machines\/'$machine'\/\(.*\)\/id/\1/p'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function __bobthefish_vagrant_id -S -a machine -a provider -d 'List Vagrant machine id'
|
|
||||||
if [ -n "$provider" ]
|
|
||||||
read id < .vagrant/machines/$machine/$provider/id
|
|
||||||
echo $id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagrant status'
|
function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagrant status'
|
||||||
set -l vagrant_status
|
set -l vagrant_status
|
||||||
set -l vm_status (VBoxManage showvminfo --machinereadable $id ^/dev/null | command grep 'VMState=' | tr -d '"' | cut -d '=' -f 2)
|
set -l vm_status (VBoxManage showvminfo --machinereadable $id ^/dev/null | command grep 'VMState=' | tr -d '"' | cut -d '=' -f 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user