]> git.lizzy.rs Git - i3-setup.git/blob - fleckenstein.zsh-theme
Create LICENSE
[i3-setup.git] / fleckenstein.zsh-theme
1 functions rbenv_prompt_info >& /dev/null || rbenv_prompt_info(){}
2
3 if [[ "$USER_ALIAS" == "" ]]; then
4         USER_ALIAS=$USER
5 fi
6
7 function theme_precmd {
8     local TERMWIDTH
9     (( TERMWIDTH = ${COLUMNS} - 1 ))
10
11
12     ###
13     # Truncate the path if it's too long.
14
15     PR_FILLBAR=""
16     PR_PWDLEN=""
17
18     if [[ "$USER_ALIAS" == "" ]]; then
19         USER_ALIAS=$USER
20     fi
21
22     if [[ "$USER_ALIAS_LENGTH" == "" ]]; then
23                 USER_ALIAS_LENGTH=${#${USER_ALIAS}}
24     fi
25
26     local promptsize=${#${(%):-------[@%m:%l)---()--}}
27     local rubyprompt=`rvm_prompt_info || rbenv_prompt_info`
28     local rubypromptsize=${#${rubyprompt}}
29     local pwdsize=${#${(%):-%~}}
30
31     if [[ "$promptsize + $rubypromptsize + $pwdsize" -gt $TERMWIDTH ]]; then
32       ((PR_PWDLEN=$TERMWIDTH - $promptsize))
33     else
34       PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $USER_ALIAS_LENGTH + $rubypromptsize + $pwdsize)))..${PR_HBAR}.)}"
35     fi
36
37 }
38
39
40 setopt extended_glob
41 theme_preexec () {
42     if [[ "$TERM" == "screen" ]]; then
43         local CMD=${1[(wr)^(*=*|sudo|-*)]}
44         echo -n "\ek$CMD\e\\"
45     fi
46 }
47
48
49 setprompt () {
50     ###
51     # Need this so the prompt will work.
52
53     setopt prompt_subst
54
55
56     ###
57     # See if we can use colors.
58
59     autoload zsh/terminfo
60     for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
61         eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
62         eval PR_LIGHT_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
63         (( count = $count + 1 ))
64     done
65     PR_NO_COLOUR="%{$terminfo[sgr0]%}"
66
67     ###
68     # Modify Git prompt
69     ZSH_THEME_GIT_PROMPT_PREFIX=" $PR_YELLOW"
70     ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
71     ZSH_THEME_GIT_PROMPT_DIRTY=""
72     ZSH_THEME_GIT_PROMPT_CLEAN=""
73
74     ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} βš‘"
75     ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} πŸš§"
76     ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} πŸ—‘️ "
77     ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} πŸ’±"
78     ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} πŸ—œοΈ "
79     ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} πŸ”°"
80
81     ###
82     # See if we can use extended characters to look nicer.
83     # UTF-8 Fixed
84
85     if [[ $(locale charmap) == "UTF-8" ]]; then
86         PR_SET_CHARSET=""
87         PR_SHIFT_IN=""
88         PR_SHIFT_OUT=""
89         PR_HBAR="─"
90         PR_ULCORNER="β”Œ"
91         PR_LLCORNER="β””"
92         PR_LRCORNER="β”˜"
93         PR_URCORNER="┐"
94     else
95         typeset -A altchar
96         set -A altchar ${(s..)terminfo[acsc]}
97         # Some stuff to help us draw nice lines
98         PR_SET_CHARSET="%{$terminfo[enacs]%}"
99         PR_SHIFT_IN="%{$terminfo[smacs]%}"
100         PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
101         PR_HBAR='$PR_SHIFT_IN${altchar[q]:--}$PR_SHIFT_OUT'
102         PR_ULCORNER='$PR_SHIFT_IN${altchar[l]:--}$PR_SHIFT_OUT'
103         PR_LLCORNER='$PR_SHIFT_IN${altchar[m]:--}$PR_SHIFT_OUT'
104         PR_LRCORNER='$PR_SHIFT_IN${altchar[j]:--}$PR_SHIFT_OUT'
105         PR_URCORNER='$PR_SHIFT_IN${altchar[k]:--}$PR_SHIFT_OUT'
106      fi
107
108
109     ###
110     # Decide if we need to set titlebar text.
111
112     #case $TERM in
113         #xterm*)
114         #   PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
115         #    ;;
116         #screen)
117         #    PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
118         #    ;;
119         #*)
120         #    PR_TITLEBAR=''
121         #    ;;
122     #esac
123
124         PR_TITLEBAR=$'%{\e]0;zsh\a%}'
125
126     ###
127     # Decide whether to set a screen title
128     if [[ "$TERM" == "screen" ]]; then
129         PR_STITLE=$'%{\ekzsh\e\\%}'
130     else
131         PR_STITLE=''
132     fi
133
134     ###
135     # Finally, the prompt.
136
137     PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
138 $PR_MAGENTA$PR_ULCORNER$PR_HBAR nya \
139 $PR_YELLOW%$PR_PWDLEN<...<%~%<< \
140 `rvm_prompt_info || rbenv_prompt_info`$PR_BLUE$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}─[\
141 $PR_GREEN$USER_ALIAS$PR_BLUE@$PR_GREEN%m:%l\
142 $PR_BLUE]$PR_BLUE$PR_HBAR$PR_URCORNER\
143
144 $PR_MAGENTA╰─%{$reset_color%}`git_prompt_info``git_prompt_status`\
145 $PR_MAGENTA Ξ» $PR_NO_COLOUR'
146
147     # display exitcode on the right when >0
148     return_code="%(?..%{$fg[red]%}%? β†΅%{$reset_color%})"
149     RPROMPT=' $return_code\
150 $PR_BLUE [$PR_GREEN%D{%a %b %d %H:%M:%S}$PR_BLUE]$PR_HBAR$PR_BLUE$PR_LRCORNER$PR_NO_COLOUR'
151
152     PS2='$PR_BLUE$PR_HBAR\
153 $PR_BLUE$PR_HBAR(\
154 $PR_LIGHT_GREEN%_$PR_BLUE)$PR_HBAR\
155 $PR_CYAN$PR_HBAR$PR_NO_COLOUR '
156 }
157
158 setprompt
159
160 autoload -U add-zsh-hook
161 add-zsh-hook precmd  theme_precmd
162 add-zsh-hook preexec theme_preexec
163
164 fortune | cowsay | lolcat -S 5