diff --git a/functions b/functions index 6109326..fa05e54 100755 --- a/functions +++ b/functions @@ -5,12 +5,6 @@ ################################################################################ -# Background changes depending on solarized theme -case ${SOLARIZED_THEME:-dark} in - light) local bkg=white;; - *) local bkg=black;; -esac - local ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}[%{$fg_bold[blue]%}" local ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[green]%}]" local ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_no_bold[green]%}✓" @@ -25,14 +19,39 @@ local ZSH_THEME_VIRTUALENV_SUFFIX="%{$reset_color$fg_bold[green]%})%{$reset_colo # Depending if root or not, displays the right prompt char # and changes the color of the username -if [[ $EUID -eq 0 ]]; then - local _USERNAME="%{$fg_bold[red]%}%n" - local _LIBERTY="%{$fg_no_bold[red]%}#" -else - local _USERNAME="%{$fg_bold[green]%}%n" - local _LIBERTY="%{$fg_no_bold[green]%}$" -fi -_LIBERTY="$_LIBERTY%{$reset_color%}" +color_username () { + if [[ $EUID -eq 0 ]]; then + echo "%{$fg_bold[red]%}%n" + else + echo "%{$fg_bold[green]%}%n" + fi +} + +color_prompt_char () { + if [[ $EUID -eq 0 ]]; then + echo "%{$fg_no_bold[red]%}#%{$reset_color%}" + else + echo "%{$fg_no_bold[green]%}$%{$reset_color%}" + fi +} + +# Host coloring, specific to Rezometz +color_host () { + local couleur_hote="" + case $HOST in + TwelveYearsAndStillGoingStrong|lharkinateur|BecauseROSThatSWhy|lharktop|blieuxor) + couleur_hote=cyan;; + chimay|orval) + couleur_hote=magenta;; + babel|taima|era|vidar|okami|athena) + couleur_hote=red;; + loki|skadi) + couleur_hote=blue;; + *) + couleur_hote=white;; + esac + echo "%{$fg_bold[$couleur_hote]%}%m" +} function virtualenv_prompt_info(){ @@ -52,7 +71,7 @@ function _prompt_chars() { local _VENV_PROMPT="%{%}$(virtualenv_prompt_info)" - echo "$_GIT_CHAR$_VENV_PROMPT $_LIBERTY" + echo "$_GIT_CHAR$_VENV_PROMPT $(color_prompt_char)" } function charge_batterie { @@ -138,10 +157,6 @@ space_sh_git_prompt () { echo $_result } -################################################################################ -# Prompt display # -################################################################################ - prompt_msg () { line=$(tail -1 /dev/shm/prompt_msg) case $line in @@ -162,18 +177,22 @@ prompt_msg () { echo $msg } +################################################################################ +# Prompt display # +################################################################################ + prompt_create () { # Carriage return to give the prompt some air PROMPT="%{$reset_color%}"$'\n' # Username, red when logged as root - PROMPT+='$_USERNAME' + PROMPT+='$(color_username)' # @ symbol PROMPT+="%{$fg_bold[blue]%}@" # Hostname, colors defined just above - PROMPT+="%{$fg_bold[$couleur_hote]%}"'%m' + PROMPT+="$(color_host)" # White space to separate host from pwd PROMPT+=" %{$reset_color%}" diff --git a/zshrc b/zshrc index 1bfa15b..701812f 100644 --- a/zshrc +++ b/zshrc @@ -146,21 +146,6 @@ EXPORTTIME=0 COMPLETION_WAITING_DOTS="true" -# Host coloring, specific to Rezometz -local couleur_hote="" -case $HOST in - TwelveYearsAndStillGoingStrong|lharkinateur|BecauseROSThatSWhy|lharktop|blieuxor) - couleur_hote=cyan;; - chimay|orval) - couleur_hote=magenta;; - babel|taima|era|vidar|okami|athena) - couleur_hote=red;; - loki|skadi) - couleur_hote=blue;; - *) - couleur_hote=white;; -esac - #Heure="%(!,%{%B$fg[red]%}%D{%a %d/%m} %T%{$reset_color%}%b,%D{%a %d/%m} %T)" # Pour recalculer les variables du prompt