commit 03deb0f13c8bd9562c60512457c29efea7a776be
parent 9ba67847c68bfb70c59fc335ca8131638d1f88c9
Author: Chris Bracken <chris@bracken.jp>
Date: Fri, 10 Nov 2017 14:58:34 -0800
Eliminate boilerplate in colour prompt check
Also cleans up a conditional expression to use == rather than =.
This was derived from some old Debian or maybe Ubuntu .bashrc defaults.
At this point, if colour is available, enable it no matter what.
Diffstat:
M | .zshrc | | | 24 | ++++++------------------ |
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/.zshrc b/.zshrc
@@ -43,38 +43,26 @@ git_branch() {
# Prompt
setopt prompt_subst
autoload -Uz colors && colors
-
-# uncomment for a colored prompt, if the terminal has the capability
-force_color_prompt=yes
-if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
-fi
-
-if [ "$color_prompt" = yes ]; then
+if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
PROMPT='%{$fg[yellow]%}%T %{$fg[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%c%{$fg[yellow]%}$(git_branch)%{$reset_color%}%# '
else
PROMPT="%T %n@%m:%c$(git_branch)%# "
fi
-unset color_prompt force_color_prompt
# If procfs is available, get the terminal executable.
term_bin=""
if [[ -e /proc/$PPID/cmdline ]]; then
term_bin="${$(</proc/$PPID/cmdline):t}"
fi
-
-if [[ "$COLORTERM" = "gnome-terminal" ]] || \
+if [[ "$COLORTERM" == "gnome-terminal" ]] || \
[[ "$term_bin" == gnome-terminal* ]] || \
[[ "$term_bin" == urxvt* ]]; then
export TERM=xterm-256color
fi
+unset term_bin
# Load path additions.
if [ -f ~/.paths ]; then