Last active
September 28, 2015 08:37
-
-
Save ygmpkk/61614452fb8cc84ec99d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="(" | |
ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX=")" | |
function virtualenv_prompt_info() { | |
if [ -n "$VIRTUAL_ENV" ]; then | |
if [ -f "$VIRTUAL_ENV/__name__" ]; then | |
local name=`cat $VIRTUAL_ENV/__name__` | |
elif [ `basename $VIRTUAL_ENV` = "__" ]; then | |
local name=$(basename $(dirname $VIRTUAL_ENV)) | |
else | |
local name=$(basename $VIRTUAL_ENV) | |
fi | |
echo "$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX$name$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX" | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Yay! High voltage and arrows! | |
prompt_setup_pygmalion(){ | |
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%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
# 时间 | |
DALLAS_CURRENT_TIME_="%{$fg[white]%}[%{$fg[yellow]%}%T%{$fg[white]%}]%{$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%} ' | |
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g") | |
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g") | |
precmd_functions+=(prompt_pygmalion_precmd) | |
} | |
prompt_pygmalion_precmd(){ | |
local gitinfo=$(git_prompt_info) | |
local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g") | |
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")" | |
local prompt_length=${#exp_nocolor} | |
local virtualenv_info=$(virtualenv_prompt_info) | |
local virtualenv_info_nocolor=$(echo "$virtualenv_info" | perl -pe "s/%\{[^}]+\}//g") | |
local nl="" | |
if [[ $prompt_length -gt 120 ]]; then | |
nl=$'\n%{\r%}'; | |
fi | |
PROMPT="$virtualenv_info$DALLAS_CURRENT_TIME_$base_prompt$gitinfo$nl$post_prompt" | |
} | |
prompt_setup_pygmalion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment