Browse code

Add new jonathan theme

Jonathan Tron authored on 16/04/2011 at 12:44:38
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,137 @@
0
+function precmd {
1
+    local TERMWIDTH
2
+    (( TERMWIDTH = ${COLUMNS} - 1 ))
3
+
4
+
5
+    ###
6
+    # Truncate the path if it's too long.
7
+    
8
+    PR_FILLBAR=""
9
+    PR_PWDLEN=""
10
+    
11
+    local promptsize=${#${(%):---(%n@%m:%l)---()--}}
12
+    local rubyprompt=`rvm_prompt_info`
13
+    local rubypromptsize=${#${rubyprompt}}
14
+    local pwdsize=${#${(%):-%~}}
15
+    
16
+    if [[ "$promptsize + $rubypromptsize + $pwdsize" -gt $TERMWIDTH ]]; then
17
+      ((PR_PWDLEN=$TERMWIDTH - $promptsize))
18
+    else
19
+      PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $rubypromptsize + $pwdsize)))..${PR_HBAR}.)}"
20
+    fi
21
+
22
+}
23
+
24
+
25
+setopt extended_glob
26
+preexec () {
27
+    if [[ "$TERM" == "screen" ]]; then
28
+	local CMD=${1[(wr)^(*=*|sudo|-*)]}
29
+	echo -n "\ek$CMD\e\\"
30
+    fi
31
+}
32
+
33
+
34
+setprompt () {
35
+    ###
36
+    # Need this so the prompt will work.
37
+
38
+    setopt prompt_subst
39
+
40
+
41
+    ###
42
+    # See if we can use colors.
43
+
44
+    autoload colors zsh/terminfo
45
+    if [[ "$terminfo[colors]" -ge 8 ]]; then
46
+	colors
47
+    fi
48
+    for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
49
+	eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
50
+	eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
51
+	(( count = $count + 1 ))
52
+    done
53
+    PR_NO_COLOUR="%{$terminfo[sgr0]%}"
54
+
55
+    ###
56
+    # Modify Git prompt
57
+    ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[green]%}"
58
+    ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
59
+    ZSH_THEME_GIT_PROMPT_DIRTY=""
60
+    ZSH_THEME_GIT_PROMPT_CLEAN=""
61
+
62
+    ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
63
+    ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
64
+    ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
65
+    ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
66
+    ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
67
+    ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
68
+
69
+    ###
70
+    # See if we can use extended characters to look nicer.
71
+    
72
+    typeset -A altchar
73
+    set -A altchar ${(s..)terminfo[acsc]}
74
+    PR_SET_CHARSET="%{$terminfo[enacs]%}"
75
+    PR_SHIFT_IN="%{$terminfo[smacs]%}"
76
+    PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
77
+    PR_HBAR=${altchar[q]:--}
78
+    PR_ULCORNER=${altchar[l]:--}
79
+    PR_LLCORNER=${altchar[m]:--}
80
+    PR_LRCORNER=${altchar[j]:--}
81
+    PR_URCORNER=${altchar[k]:--}
82
+
83
+    
84
+    ###
85
+    # Decide if we need to set titlebar text.
86
+    
87
+    case $TERM in
88
+	xterm*)
89
+	    PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
90
+	    ;;
91
+	screen)
92
+	    PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
93
+	    ;;
94
+	*)
95
+	    PR_TITLEBAR=''
96
+	    ;;
97
+    esac
98
+    
99
+    
100
+    ###
101
+    # Decide whether to set a screen title
102
+    if [[ "$TERM" == "screen" ]]; then
103
+	PR_STITLE=$'%{\ekzsh\e\\%}'
104
+    else
105
+	PR_STITLE=''
106
+    fi
107
+    
108
+    
109
+    ###
110
+    # Finally, the prompt.
111
+
112
+    PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
113
+$PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_HBAR$PR_SHIFT_OUT$PR_GREY(\
114
+$PR_GREEN%$PR_PWDLEN<...<%~%<<\
115
+$PR_GREY)`rvm_prompt_info`$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}$PR_HBAR$PR_SHIFT_OUT$PR_GREY(\
116
+$PR_CYAN%(!.%SROOT%s.%n)$PR_GREY@$PR_GREEN%m:%l\
117
+$PR_GREY)$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_URCORNER$PR_SHIFT_OUT\
118
+
119
+$PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
120
+$PR_YELLOW%D{%H:%M:%S}\
121
+$PR_LIGHT_BLUE%{$reset_color%}`git_prompt_info``git_prompt_status`$PR_BLUE)$PR_CYAN$PR_SHIFT_IN$PR_HBAR\
122
+$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
123
+>$PR_NO_COLOUR '
124
+
125
+    # display exitcode on the right when >0
126
+    return_code="%(?..%{$fg[red]%}%? ↵ %{$reset_color%})"
127
+    RPROMPT=' $return_code$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\
128
+($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR'
129
+
130
+    PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
131
+$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
132
+$PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
133
+$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '
134
+}
135
+
136
+setprompt