vagrant-prompt.plugin.zsh 711 B

123456789101112131415161718
  1. function vagrant_prompt_info() {
  2. if [[ ! -d .vagrant || ! -f Vagrantfile ]]; then
  3. return
  4. fi
  5. local vm_states vm_state
  6. vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^[^ ]* *([[:alnum:] ]*) \([[:alnum:]_]+\)$/\1/p')"})
  7. printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
  8. for vm_state in $vm_states; do
  9. case "$vm_state" in
  10. running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
  11. "not running"|poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
  12. paused|saved|suspended) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
  13. "not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
  14. esac
  15. done
  16. printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
  17. }