mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-17 23:57:52 +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]%}○"
|
# 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
|
||||||
|
|||||||
@ -17,6 +17,8 @@ function _virtualenv_prompt_info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prompt_setup_pygmalion(){
|
prompt_setup_pygmalion(){
|
||||||
|
setopt localoptions extendedglob
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$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%}'
|
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%} '
|
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
|
||||||
|
|
||||||
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
|
||||||
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
add-zsh-hook precmd prompt_pygmalion_precmd
|
add-zsh-hook precmd prompt_pygmalion_precmd
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_pygmalion_precmd(){
|
prompt_pygmalion_precmd(){
|
||||||
|
setopt localoptions extendedglob
|
||||||
|
|
||||||
local gitinfo=$(git_prompt_info)
|
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 exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
||||||
local prompt_length=${#exp_nocolor}
|
local prompt_length=${#exp_nocolor}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
# Yay! High voltage and arrows!
|
# Yay! High voltage and arrows!
|
||||||
|
|
||||||
prompt_setup_pygmalion(){
|
prompt_setup_pygmalion(){
|
||||||
|
setopt localoptions extendedglob
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$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%}'
|
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%} '
|
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
|
||||||
|
|
||||||
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
|
||||||
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
|
post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
add-zsh-hook precmd prompt_pygmalion_precmd
|
add-zsh-hook precmd prompt_pygmalion_precmd
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_pygmalion_precmd(){
|
prompt_pygmalion_precmd(){
|
||||||
|
setopt localoptions extendedglob
|
||||||
|
|
||||||
local gitinfo=$(git_prompt_info)
|
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 exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
||||||
local prompt_length=${#exp_nocolor}
|
local prompt_length=${#exp_nocolor}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user