mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +01:00
parent
8d08f1634a
commit
4c9fc2634b
1 changed files with 10 additions and 15 deletions
|
@ -16,22 +16,17 @@
|
||||||
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
|
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
|
||||||
|
|
||||||
function vagrant_prompt_info() {
|
function vagrant_prompt_info() {
|
||||||
test -d .vagrant && test -f Vagrantfile
|
local vm_states vm_state
|
||||||
if [[ "$?" == "0" ]]; then
|
if [[ -d .vagrant && -f Vagrantfile ]]; then
|
||||||
statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
|
vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^.*(saved|poweroff|running|not created) \([[:alnum:]_]+\)$/\1/p')"})
|
||||||
statuses=("${(f)statuses}")
|
|
||||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
|
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
|
||||||
for vm_details in $statuses; do
|
for vm_state in $vm_states; do
|
||||||
vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
|
case "$vm_state" in
|
||||||
if [[ "$vm_state" == "running" ]]; then
|
saved) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
|
||||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
|
running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
|
||||||
elif [[ "$vm_state" == "saved" ]]; then
|
poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
|
||||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
|
"not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
|
||||||
elif [[ "$vm_state" == "not created" ]]; then
|
esac
|
||||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED
|
|
||||||
elif [[ "$vm_state" == "poweroff" ]]; then
|
|
||||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
|
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue