]> err.no Git - dotfiles/commitdiff
Add color support
authortfheen <tfheen@8da78d58-1cd3-0310-bee5-d77bd1b3e8bf>
Mon, 4 Apr 2011 12:57:28 +0000 (12:57 +0000)
committertfheen <tfheen@8da78d58-1cd3-0310-bee5-d77bd1b3e8bf>
Mon, 4 Apr 2011 12:57:28 +0000 (12:57 +0000)
git-svn-id: file:///svn/tfheen/trunk/dotfiles@1458 8da78d58-1cd3-0310-bee5-d77bd1b3e8bf

zshrc
zshrc.d/00_spectrum [new file with mode: 0644]

diff --git a/zshrc b/zshrc
index fd89de2593420e5252cf09e4bea5d3d47bf5b2c8..402985b8d003a6c993ff672d4cd43ac740e251af 100644 (file)
--- 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 (file)
index 0000000..f54b7ec
--- /dev/null
@@ -0,0 +1,21 @@
+#! /bin/zsh
+# A script to make using 256 colors in zsh less painful.
+# P.C. Shyamshankar <sykora@lucentbeing.com>
+#
+# From https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
+
+typeset -Ag FX FG BG
+
+FX=(
+    reset     "\e[00m"
+    bold      "\e[01m" no-bold      "\e[22m"
+    italic    "\e[03m" no-italic    "\e[23m"
+    underline "\e[04m" no-underline "\e[24m"
+    blink     "\e[05m" no-blink     "\e[25m"
+    reverse   "\e[07m" no-reverse   "\e[27m"
+)
+
+for color in {000..255}; do
+    FG[$color]="\e[38;5;${color}m"
+    BG[$color]="\e[48;5;${color}m"
+done