]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/themes/michelebologna.zsh-theme
bb86d68db074514d33ad4d5c3d5360f5d3865009
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / themes / michelebologna.zsh-theme
1 # Michele Bologna's theme
2 # https://www.michelebologna.net
3 #
4 # This a theme for oh-my-zsh. Features a colored prompt with:
5 # * username@host: [jobs] [git] workdir %
6 # * hostname color is based on hostname characters. When using as root, the
7 # prompt shows only the hostname in red color.
8 # * [jobs], if applicable, counts the number of suspended jobs tty
9 # * [git], if applicable, represents the status of your git repo (more on that
10 # later)
11 # * '%' prompt will be green if last command return value is 0, yellow otherwise.
12 #
13 # git prompt is inspired by official git contrib prompt:
14 # https://github.com/git/git/tree/master/contrib/completion/git-prompt.sh
15 # and it adds:
16 # * the current branch
17 # * '%' if there are untracked files
18 # * '$' if there are stashed changes
19 # * '*' if there are modified files
20 # * '+' if there are added files
21 # * '<' if local repo is behind remote repo
22 # * '>' if local repo is ahead remote repo
23 # * '=' if local repo is equal to remote repo (in sync)
24 # * '<>' if local repo is diverged
25
26 local green="%{$fg_bold[green]%}"
27 local red="%{$fg_bold[red]%}"
28 local cyan="%{$fg_bold[cyan]%}"
29 local yellow="%{$fg_bold[yellow]%}"
30 local blue="%{$fg_bold[blue]%}"
31 local magenta="%{$fg_bold[magenta]%}"
32 local white="%{$fg_bold[white]%}"
33 local reset="%{$reset_color%}"
34
35 local -a color_array
36 color_array=($green $red $cyan $yellow $blue $magenta $white)
37
38 local username_color=$white
39 local hostname_color=$color_array[$[((#HOST))%7+1]] # choose hostname color based on first character
40 local current_dir_color=$blue
41
42 local username="%n"
43 local hostname="%m"
44 local current_dir="%~"
45
46 local username_output="%(!..${username_color}${username}${reset}@)"
47 local hostname_output="${hostname_color}${hostname}${reset}"
48 local current_dir_output="${current_dir_color}${current_dir}${reset}"
49 local jobs_bg="${red}fg: %j$reset"
50 local last_command_output="%(?.%(!.$red.$green).$yellow)"
51
52 ZSH_THEME_GIT_PROMPT_PREFIX=""
53 ZSH_THEME_GIT_PROMPT_SUFFIX=""
54 ZSH_THEME_GIT_PROMPT_DIRTY=""
55 ZSH_THEME_GIT_PROMPT_CLEAN=""
56 ZSH_THEME_GIT_PROMPT_UNTRACKED="$blue%%"
57 ZSH_THEME_GIT_PROMPT_MODIFIED="$red*"
58 ZSH_THEME_GIT_PROMPT_ADDED="$green+"
59 ZSH_THEME_GIT_PROMPT_STASHED="$blue$"
60 ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="$green="
61 ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
62 ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
63 ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="$red<>"
64
65 function michelebologna_git_prompt {
66   local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status)
67   [[ -n $out ]] || return
68   printf " %s(%s%s%s)%s" \
69     "%{$fg_bold[white]%}" \
70     "%{$fg_bold[green]%}" \
71     "$out" \
72     "%{$fg_bold[white]%}" \
73     "%{$reset_color%}"
74 }
75
76 PROMPT="$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)"
77 PROMPT+='$(michelebologna_git_prompt)'
78 PROMPT+=" $last_command_output%#$reset "
79 RPROMPT=''