Fix prompt creation bug & cleaned up prompt code
This commit is contained in:
parent
68984ff8c1
commit
dd98a17e7c
2 changed files with 40 additions and 36 deletions
61
functions
61
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_PREFIX="%{$fg_bold[green]%}[%{$fg_bold[blue]%}"
|
||||||
local ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[green]%}]"
|
local ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[green]%}]"
|
||||||
local ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_no_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
|
# Depending if root or not, displays the right prompt char
|
||||||
# and changes the color of the username
|
# and changes the color of the username
|
||||||
if [[ $EUID -eq 0 ]]; then
|
color_username () {
|
||||||
local _USERNAME="%{$fg_bold[red]%}%n"
|
if [[ $EUID -eq 0 ]]; then
|
||||||
local _LIBERTY="%{$fg_no_bold[red]%}#"
|
echo "%{$fg_bold[red]%}%n"
|
||||||
else
|
else
|
||||||
local _USERNAME="%{$fg_bold[green]%}%n"
|
echo "%{$fg_bold[green]%}%n"
|
||||||
local _LIBERTY="%{$fg_no_bold[green]%}$"
|
fi
|
||||||
fi
|
}
|
||||||
_LIBERTY="$_LIBERTY%{$reset_color%}"
|
|
||||||
|
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(){
|
function virtualenv_prompt_info(){
|
||||||
|
@ -52,7 +71,7 @@ function _prompt_chars() {
|
||||||
|
|
||||||
local _VENV_PROMPT="%{%}$(virtualenv_prompt_info)"
|
local _VENV_PROMPT="%{%}$(virtualenv_prompt_info)"
|
||||||
|
|
||||||
echo "$_GIT_CHAR$_VENV_PROMPT $_LIBERTY"
|
echo "$_GIT_CHAR$_VENV_PROMPT $(color_prompt_char)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function charge_batterie {
|
function charge_batterie {
|
||||||
|
@ -138,10 +157,6 @@ space_sh_git_prompt () {
|
||||||
echo $_result
|
echo $_result
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Prompt display #
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
prompt_msg () {
|
prompt_msg () {
|
||||||
line=$(tail -1 /dev/shm/prompt_msg)
|
line=$(tail -1 /dev/shm/prompt_msg)
|
||||||
case $line in
|
case $line in
|
||||||
|
@ -162,18 +177,22 @@ prompt_msg () {
|
||||||
echo $msg
|
echo $msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Prompt display #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
prompt_create () {
|
prompt_create () {
|
||||||
# Carriage return to give the prompt some air
|
# Carriage return to give the prompt some air
|
||||||
PROMPT="%{$reset_color%}"$'\n'
|
PROMPT="%{$reset_color%}"$'\n'
|
||||||
|
|
||||||
# Username, red when logged as root
|
# Username, red when logged as root
|
||||||
PROMPT+='$_USERNAME'
|
PROMPT+='$(color_username)'
|
||||||
|
|
||||||
# @ symbol
|
# @ symbol
|
||||||
PROMPT+="%{$fg_bold[blue]%}@"
|
PROMPT+="%{$fg_bold[blue]%}@"
|
||||||
|
|
||||||
# Hostname, colors defined just above
|
# Hostname, colors defined just above
|
||||||
PROMPT+="%{$fg_bold[$couleur_hote]%}"'%m'
|
PROMPT+="$(color_host)"
|
||||||
|
|
||||||
# White space to separate host from pwd
|
# White space to separate host from pwd
|
||||||
PROMPT+=" %{$reset_color%}"
|
PROMPT+=" %{$reset_color%}"
|
||||||
|
|
15
zshrc
15
zshrc
|
@ -146,21 +146,6 @@ EXPORTTIME=0
|
||||||
COMPLETION_WAITING_DOTS="true"
|
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)"
|
#Heure="%(!,%{%B$fg[red]%}%D{%a %d/%m} %T%{$reset_color%}%b,%D{%a %d/%m} %T)"
|
||||||
|
|
||||||
# Pour recalculer les variables du prompt
|
# Pour recalculer les variables du prompt
|
||||||
|
|
Loading…
Reference in a new issue