1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-21 00:57:24 +08:00

Compare commits

..

No commits in common. "4ed6fd2b8b6a0efb2f84f00a64503282aca260e7" and "8d08f1634a7b9782e3722ce770e8630f569afe3f" have entirely different histories.

3 changed files with 21 additions and 24 deletions

View File

@ -16,17 +16,22 @@
# 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() {
local vm_states vm_state test -d .vagrant && test -f Vagrantfile
if [[ -d .vagrant && -f Vagrantfile ]]; then if [[ "$?" == "0" ]]; then
vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^.*(saved|poweroff|running|not created) \([[:alnum:]_]+\)$/\1/p')"}) statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
statuses=("${(f)statuses}")
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
for vm_state in $vm_states; do for vm_details in $statuses; do
case "$vm_state" in vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
saved) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;; if [[ "$vm_state" == "running" ]]; then
running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;; printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;; elif [[ "$vm_state" == "saved" ]]; then
"not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;; printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
esac 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
done done
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
fi fi

View File

@ -17,8 +17,6 @@ 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%}"
@ -27,18 +25,16 @@ 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=${base_prompt//\%\{[^\}]##\}} base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}} post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
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=${gitinfo//\%\{[^\}]##\}} local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
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}

View File

@ -1,8 +1,6 @@
# 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%}"
@ -11,18 +9,16 @@ 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=${base_prompt//\%\{[^\}]##\}} base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}} post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
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=${gitinfo//\%\{[^\}]##\}} local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
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}