mirror of
https://github.com/oh-my-fish/theme-bobthefish.git
synced 2024-10-27 20:34:23 +00:00
Add rudimentary VMWare vagrant support.
Drive-by: simplify existing virtualbox support a bit.
This commit is contained in:
parent
1f13fd0888
commit
ad36c7ada5
@ -87,7 +87,7 @@ set -g default_user your_normal_user
|
||||
|
||||
**Prompt options**
|
||||
- `theme_display_ruby`. Use `no` to completely hide all information about Ruby version. By default Ruby version displayed if there is the difference from default settings.
|
||||
- `theme_display_vagrant`. This feature is disabled by default, use `yes` to display Vagrant status in your prompt. Please note, only VirtualBox provider is supported.
|
||||
- `theme_display_vagrant`. This feature is disabled by default, use `yes` to display Vagrant status in your prompt. Please note that only the VirtualBox and VMWare providers are supported.
|
||||
|
||||
[fish]: https://github.com/fish-shell/fish-shell
|
||||
[screenshot]: http://i.0x7f.us/bobthefish.png
|
||||
|
@ -190,37 +190,61 @@ end
|
||||
|
||||
function __bobthefish_prompt_vagrant -S -d 'Display Vagrant status'
|
||||
[ "$theme_display_vagrant" != 'yes' ]; and return
|
||||
which VBoxManage >/dev/null 2>&1; and set -l __vbox_installed yes
|
||||
if [ -f Vagrantfile -a "$__vbox_installed" = 'yes' ]
|
||||
# Get machine UUIDs
|
||||
set -e __vagrant_ids
|
||||
set -e __vagrant_statuses
|
||||
for m in .vagrant/machines/**/id
|
||||
set -l __machine_id (cat $m)
|
||||
set __vagrant_ids $__vagrant_ids $__machine_id
|
||||
end
|
||||
for i in $__vagrant_ids
|
||||
set -l __vm_status (VBoxManage showvminfo --machinereadable $i 2>/dev/null | grep 'VMState=' | tr -d '"' | cut -d '=' -f 2)
|
||||
set __vagrant_statuses "$__vagrant_statuses<$__vm_status>"
|
||||
end
|
||||
# Transform statuses to glyphs
|
||||
set __vagrant_statuses ( echo -n $__vagrant_statuses | sed \
|
||||
-e "s#<running>#$__bobthefish_vagrant_running_glyph#g" \
|
||||
-e "s#<poweroff>#$__bobthefish_vagrant_poweroff_glyph#g" \
|
||||
-e "s#<aborted>#$__bobthefish_vagrant_aborted_glyph#g" \
|
||||
-e "s#<saved>#$__bobthefish_vagrant_saved_glyph#g" \
|
||||
-e "s#<stopping>#$__bobthefish_vagrant_stopping_glyph#g" \
|
||||
-e "s#<>#$__bobthefish_vagrant_unknown_glyph#g"
|
||||
)
|
||||
# Display status if any status
|
||||
if [ "$__vagrant_statuses" != '' ]
|
||||
__bobthefish_start_segment $__bobthefish_vagrant fff --bold
|
||||
echo -n -s "$__vagrant_statuses "
|
||||
set_color normal
|
||||
if [ -f Vagrantfile ]
|
||||
if type -q VBoxManage
|
||||
__bobthefish_prompt_vagrant_vbox
|
||||
else if type -q vmrun
|
||||
__bobthefish_prompt_vagrant_vmware
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __bobthefish_vagrant_vmware_ids -S -d 'List Vagrant machine ids'
|
||||
cat .vagrant/machines/**/id
|
||||
end
|
||||
|
||||
function __bobthefish_prompt_vagrant_vbox -S -d 'Display VirtualBox Vagrant status'
|
||||
set -l vagrant_status
|
||||
for id in __bobthefish_vagrant_ids
|
||||
set -l vm_status (VBoxManage showvminfo --machinereadable $id 2>/dev/null | grep 'VMState=' | tr -d '"' | cut -d '=' -f 2)
|
||||
switch "$vm_status"
|
||||
case 'running'
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_running_glyph"
|
||||
case 'poweroff'
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_poweroff_glyph"
|
||||
case 'aborted'
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_aborted_glyph"
|
||||
case 'saved'
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_saved_glyph"
|
||||
case 'stopping'
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_stopping_glyph"
|
||||
case ''
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_unknown_glyph"
|
||||
end
|
||||
end
|
||||
[ -z "$vagrant_status"]; and return
|
||||
|
||||
__bobthefish_start_segment $__bobthefish_vagrant fff --bold
|
||||
echo -n -s "$vagrant_status "
|
||||
set_color normal
|
||||
end
|
||||
|
||||
function __bobthefish_prompt_vagrant_vmware -S -d 'Display VMWare Vagrant status'
|
||||
set -l vagrant_status
|
||||
for id in (__bobthefish_vagrant_ids)
|
||||
if [ (pgrep -f "$id") ]
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_running_glyph"
|
||||
else
|
||||
set vagrant_status "$vagrant_status$__bobthefish_vagrant_poweroff_glyph"
|
||||
end
|
||||
end
|
||||
[ -z "$vagrant_status" ]; and return
|
||||
|
||||
__bobthefish_start_segment $__bobthefish_vagrant fff --bold
|
||||
echo -n -s "$vagrant_status "
|
||||
set_color normal
|
||||
end
|
||||
|
||||
function __bobthefish_prompt_status -S -a last_status -d 'Display symbols for a non zero exit status, root and background jobs'
|
||||
set -l nonzero
|
||||
set -l superuser
|
||||
|
Loading…
Reference in New Issue
Block a user