mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-07 21:18:01 +08:00
Compare commits
2 Commits
8d08f1634a
...
4ed6fd2b8b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ed6fd2b8b | ||
|
|
4c9fc2634b |
@ -16,22 +16,17 @@
|
||||
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
|
||||
|
||||
function vagrant_prompt_info() {
|
||||
test -d .vagrant && test -f Vagrantfile
|
||||
if [[ "$?" == "0" ]]; then
|
||||
statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
|
||||
statuses=("${(f)statuses}")
|
||||
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_details in $statuses; do
|
||||
vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
|
||||
if [[ "$vm_state" == "running" ]]; then
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
|
||||
elif [[ "$vm_state" == "saved" ]]; then
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
|
||||
elif [[ "$vm_state" == "not created" ]]; then
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED
|
||||
elif [[ "$vm_state" == "poweroff" ]]; then
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF
|
||||
fi
|
||||
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
|
||||
fi
|
||||
|
||||
@ -17,6 +17,8 @@ function _virtualenv_prompt_info {
|
||||
}
|
||||
|
||||
prompt_setup_pygmalion(){
|
||||
setopt localoptions extendedglob
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
|
||||
@ -25,16 +27,18 @@ prompt_setup_pygmalion(){
|
||||
base_prompt='$(_virtualenv_prompt_info)%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
|
||||
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
|
||||
|
||||
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
||||
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
||||
base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
|
||||
post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd prompt_pygmalion_precmd
|
||||
}
|
||||
|
||||
prompt_pygmalion_precmd(){
|
||||
setopt localoptions extendedglob
|
||||
|
||||
local gitinfo=$(git_prompt_info)
|
||||
local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
|
||||
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
||||
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
||||
local prompt_length=${#exp_nocolor}
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
# Yay! High voltage and arrows!
|
||||
|
||||
prompt_setup_pygmalion(){
|
||||
setopt localoptions extendedglob
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
|
||||
@ -9,16 +11,18 @@ prompt_setup_pygmalion(){
|
||||
base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
|
||||
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
|
||||
|
||||
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
||||
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
||||
base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
|
||||
post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd prompt_pygmalion_precmd
|
||||
}
|
||||
|
||||
prompt_pygmalion_precmd(){
|
||||
setopt localoptions extendedglob
|
||||
|
||||
local gitinfo=$(git_prompt_info)
|
||||
local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
|
||||
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
||||
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
||||
local prompt_length=${#exp_nocolor}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user