forked from fjpalacios/elessar-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elessar.zsh-theme
45 lines (39 loc) · 1.46 KB
/
elessar.zsh-theme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Based on Gitster theme with a few improvements
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
function get_pwd(){
git_root=$PWD
while [[ $git_root != / && ! -e $git_root/.git ]]; do
git_root=$git_root:h
done
if [[ $git_root = / ]]; then
unset git_root
prompt_short_dir=%~
else
parent=${git_root%\/*}
prompt_short_dir=${%F{38}PWD#$parent/%f}
fi
echo $prompt_short_dir
}
function get_git_status() {
if [[ -n $(git rev-parse --is-inside-work-tree 2>/dev/null) ]]; then
local git_status="$(git_prompt_status)"
if [[ -n $git_status ]]; then
git_status="($git_status%{$reset_color%}) "
fi
echo $git_status
fi
}
PROMPT='$ret_status %{$fg[white]%}$(get_pwd) $(git_prompt_info)$(get_git_status)'
# Git info
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[220]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[129]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[41]%}✓%{$reset_color%}"
# Git status
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[41]%}+%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}-%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[129]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[38]%}>%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[172]%}=%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[7]%}?%{$reset_color%}"