zshrc: Better way to set colors
This commit is contained in:
parent
397f54b02d
commit
eb1a601086
1 changed files with 4 additions and 13 deletions
17
zshrc
17
zshrc
|
@ -67,18 +67,11 @@ case $TERM_PROGRAM in
|
|||
;;
|
||||
esac
|
||||
|
||||
__color() { print "%{\e[$1m%}" }
|
||||
__color_256() { __color "38;5;$1" }
|
||||
__reset_color() { __color 0 }
|
||||
|
||||
set_prompt() {
|
||||
PS1="$(__color_256 23)%m "
|
||||
PS1+="$(__color_256 29)%c"
|
||||
PS1+="$@$(__color_256 36)%B%(!.#.>)$(__reset_color) "
|
||||
PS1="%F{23}%m %F{29}%c$1%F{36}%(!.#.>)%f "
|
||||
PS2="%B>%b "
|
||||
RPS1="%(1j.$(__color "1;33")%j$(__reset_color).)"
|
||||
RPS1+="%(?..%(1j. .)$(__color "1;31")%?$(__reset_color))"
|
||||
RPS2="%(1_.$(__color "1;30")(%_%)$(__reset_color).)"
|
||||
RPS1="%(1j.%F{yellow}%j%f.)%(?..%(1j. .)%F{red}%?%f)"
|
||||
RPS2="%(1_.%F{black}%B(%_%)%b%f.)"
|
||||
}
|
||||
set_prompt
|
||||
|
||||
|
@ -88,8 +81,7 @@ __precmd() {
|
|||
local branch_name=$(git symbolic-ref HEAD 2>/dev/null)
|
||||
branch_name=${branch_name##refs/heads/}
|
||||
if [ -n "$branch_name" -a "$branch_name" != master ]; then
|
||||
local branch="$(__color_256 36)($(__color_256 78)$branch_name"
|
||||
branch+="$(__color_256 36))"
|
||||
local branch="%F{36}(%F{78}$branch_name%F{36})"
|
||||
fi
|
||||
set_prompt $branch
|
||||
}
|
||||
|
@ -109,7 +101,6 @@ case $TERM in
|
|||
__precmd
|
||||
}
|
||||
}
|
||||
|
||||
unset_title
|
||||
;;
|
||||
*)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue