1417111bad20ec4da6747a9a11b2904a58c6e7f8

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1453 from simonoff/master

new theme and rvm theming support

Diff

This diff is truncated to protect this page.

  1diff --git a/lib/rvm.zsh b/lib/rvm.zsh
  2index cb870a9bbca96bfa1f3a1d795510daf1ef7c63b4..e8744e61e373799201c3d55f4777f47be8728135 100644
  3--- a/lib/rvm.zsh
  4+++ b/lib/rvm.zsh
  5@@ -1,5 +1,8 @@
  6-# get the name of the branch we are on
  7+# get the name of the ruby version
  8 function rvm_prompt_info() {
  9-  ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return
 10-  [[ ! -z $ruby_version ]] && echo "($ruby_version)"
 11+  [ -f $HOME/.rvm/bin/rvm-prompt ] || return
 12+  local rvm_prompt
 13+  rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
 14+  [[ "${rvm_prompt}x" == "x" ]] && return
 15+  echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
 16 }
 17diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme
 18new file mode 100644
 19index 0000000000000000000000000000000000000000..fb4d32e2419a42d759af0bc224912c68c7b9117b
 20--- /dev/null
 21+++ b/themes/simonoff.zsh-theme
 22@@ -0,0 +1,141 @@
 23+# Prompt
 24+#
 25+# Below are the color init strings for the basic file types. A color init
 26+# string consists of one or more of the following numeric codes:
 27+# Attribute codes:
 28+# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
 29+# Text color codes:
 30+# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
 31+# Background color codes:
 32+# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
 33+function precmd {
 34+
 35+    local TERMWIDTH
 36+    (( TERMWIDTH = ${COLUMNS} - 1 ))
 37+
 38+
 39+    ###
 40+    # Truncate the path if it's too long.
 41+
 42+    PR_FILLBAR=""
 43+    PR_PWDLEN=""
 44+
 45+    local promptsize=${#${(%):---(%n@%M:%l)---()}}
 46+    local pwdsize=${#${(%):-%~}}
 47+    local gitbranch="$(git_prompt_info)"
 48+    local rvmprompt="$(rvm_prompt_info)"
 49+    local gitbranchsize=${#${gitbranch:-''}}
 50+    local rvmpromptsize=${#${rvmprompt:-''}}
 51+
 52+    if [[ "$promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize" -gt $TERMWIDTH ]]; then
 53+        ((PR_PWDLEN=$TERMWIDTH - $promptsize))
 54+    else
 55+        PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize)))..${PR_SPACE}.)}"
 56+    fi
 57+}
 58+
 59+
 60+setopt extended_glob
 61+
 62+preexec () {
 63+    if [[ "$TERM" == "screen" ]]; then
 64+        local CMD=${1[(wr)^(*=*|sudo|-*)]}
 65+        echo -n "\ek$CMD\e\\"
 66+    fi
 67+
 68+    if [[ "$TERM" == "xterm" ]]; then
 69+        print -Pn "\e]0;$1\a"
 70+    fi
 71+
 72+    if [[ "$TERM" == "rxvt" ]]; then
 73+        print -Pn "\e]0;$1\a"
 74+    fi
 75+
 76+}
 77+
 78+setprompt () {
 79+###
 80+# Need this so the prompt will work.
 81+
 82+    setopt prompt_subst
 83+
 84+
 85+###
 86+# See if we can use colors.
 87+
 88+    autoload colors zsh/terminfo
 89+    if [[ "$terminfo[colors]" -ge 8 ]]; then
 90+    colors
 91+    fi
 92+    for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
 93+    eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
 94+    eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
 95+    (( count = $count + 1 ))
 96+    done
 97+    PR_NO_COLOUR="%{$terminfo[sgr0]%}"
 98+
 99+
100+###
101+# See if we can use extended characters to look nicer.
102+
103+    typeset -A altchar
104+#    set -A altchar "${(s..)terminfo[acsc]}"
105+    PR_SET_CHARSET="%{$terminfo[enacs]%}"
106+    PR_HBAR=${altchar[q]:--}
107+    PR_ULCORNER=${altchar[l]:--}
108+    PR_LLCORNER=${altchar[m]:--}
109+    PR_LRCORNER=${altchar[j]:--}
110+    PR_URCORNER=${altchar[k]:--}
111+
112+    ###
113+    # Modify Git prompt
114+    ZSH_THEME_GIT_PROMPT_PREFIX=" ["
115+    ZSH_THEME_GIT_PROMPT_SUFFIX="]"
116+    ###
117+    # Modify RVM prompt
118+    ZSH_THEME_RVM_PROMPT_PREFIX=" ["
119+    ZSH_THEME_RVM_PROMPT_SUFFIX="]"
120+
121+