summaryrefslogtreecommitdiff
path: root/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
diff options
context:
space:
mode:
authorMarc Cornellà <marc@mcornella.com>2024-10-27 17:31:38 +0100
committerGitHub <noreply@github.com>2024-10-27 17:31:38 +0100
commitfa64758aeaeb17abdefca5d193c1002230048977 (patch)
tree8182790f0bd6e995cf1b1b9b12d35853467df6bf /plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
parent68d189cb35b9826dc186f1697a501314a63e6fe2 (diff)
downloadzsh-fa64758aeaeb17abdefca5d193c1002230048977.tar.gz
zsh-fa64758aeaeb17abdefca5d193c1002230048977.tar.bz2
zsh-fa64758aeaeb17abdefca5d193c1002230048977.zip
fix(vagrant-prompt): make `vagrant_prompt_info` generic for any state (#12782)
Diffstat (limited to 'plugins/vagrant-prompt/vagrant-prompt.plugin.zsh')
-rw-r--r--plugins/vagrant-prompt/vagrant-prompt.plugin.zsh28
1 files changed, 15 insertions, 13 deletions
diff --git a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
index 29f4038c5..2d8455a53 100644
--- a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
+++ b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
@@ -1,16 +1,18 @@
function vagrant_prompt_info() {
- local vm_states vm_state
- if [[ -d .vagrant && -f Vagrantfile ]]; then
- vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^.*(saved|poweroff|running|not created) \([[:alnum:]_]+\)$/\1/p')"})
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
- for vm_state in $vm_states; do
- case "$vm_state" in
- saved) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
- running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
- poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
- "not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
- esac
- done
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
+ if [[ ! -d .vagrant || ! -f Vagrantfile ]]; then
+ return
fi
+
+ local vm_states vm_state
+ vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^[^ ]* *([[:alnum:] ]*) \([[:alnum:]_]+\)$/\1/p')"})
+ printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
+ for vm_state in $vm_states; do
+ case "$vm_state" in
+ running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
+ "not running"|poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
+ paused|saved|suspended) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
+ "not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
+ esac
+ done
+ printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
}