-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathelessar.zsh-theme
57 lines (50 loc) · 1.83 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
46
47
48
49
50
51
52
53
54
55
56
57
# 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 directoryFirst=false
local multiline=false
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=${PWD#$parent/}
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
}
function get_prompt() {
local prompt="$ret_status%{$fg[white]%}$(get_pwd) $(git_prompt_info)$(get_git_status)"
if "$multiline"; then
prompt="%{$fg[white]%}$(get_pwd) $(git_prompt_info)$(get_git_status)\n$ret_status"
elif "$directoryFirst"; then
prompt="%{$fg[cyan]%}$(get_pwd) $(git_prompt_info)$(get_git_status)$ret_status%{$reset_color%}"
fi
echo $prompt
}
PROMPT='$(get_prompt)'
# Git info
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✓%{$reset_color%}"
# Git status
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}+%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}-%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[magenta]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}>%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}=%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[yellow]%}?%{$reset_color%}"