From be8f7d1eab347ebc5e9c51a696f5ec3ae510584f Mon Sep 17 00:00:00 2001 From: tfheen Date: Mon, 4 Apr 2011 12:57:28 +0000 Subject: [PATCH] Add color support git-svn-id: file:///svn/tfheen/trunk/dotfiles@1458 8da78d58-1cd3-0310-bee5-d77bd1b3e8bf --- zshrc | 7 ++++++- zshrc.d/00_spectrum | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 zshrc.d/00_spectrum diff --git a/zshrc b/zshrc index fd89de2..402985b 100644 --- a/zshrc +++ b/zshrc @@ -35,7 +35,12 @@ if [ $ZSH_VERSION = 4.3.6 ]; then FG_BLACK=$(tput setf 0) PROMPT=': %(!.%{'"$FG_RED"'%}.)%U%n@%m%u%(!.%{'"$FG_BLACK"'%}.)'${CHROOT}' ${vcs_info_msg_0_}%B%30<..<%~%b %(!.#.>) ' else - PROMPT=': %(!.%F{red}.)%U%n@%m%u%(!.%f.)'${CHROOT}' ${vcs_info_msg_0_}%B%30<..<%~%b %(!.#.>) ' + if [ -z "$SSH_CONNECTION" ]; then + FG_HOST="$(printf "%.3d" "${$(echo ${SSH_CONNECTION%% *} | md5sum):0:2}")" + BG_HOST="$(printf "%.3d" "$(( 256 - $FG_HOST ))")" + fi + + PROMPT=': %(!.%F{red}.)%U%n%(!.%f.)@%{$FG[$FG_HOST]$BG[$BG_HOST]%}%m%u%f%k'${CHROOT}' ${vcs_info_msg_0_}%B%30<..<%~%b %(!.#.>) ' fi case `uname -s` in diff --git a/zshrc.d/00_spectrum b/zshrc.d/00_spectrum new file mode 100644 index 0000000..f54b7ec --- /dev/null +++ b/zshrc.d/00_spectrum @@ -0,0 +1,21 @@ +#! /bin/zsh +# A script to make using 256 colors in zsh less painful. +# P.C. Shyamshankar +# +# From https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ + +typeset -Ag FX FG BG + +FX=( + reset "" + bold "" no-bold "" + italic "" no-italic "" + underline "" no-underline "" + blink "" no-blink "" + reverse "" no-reverse "" +) + +for color in {000..255}; do + FG[$color]="[38;5;${color}m" + BG[$color]="[48;5;${color}m" +done -- 2.39.5