Blame view

repos/robbyrussell/oh-my-zsh/themes/michelebologna.zsh-theme 2.78 KB
238d8e65a   mj   Squashed 'repos/r...
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
58
  # Michele Bologna's theme
  # http://michelebologna.net
  #
  # This a theme for oh-my-zsh. Features a colored prompt with:
  # * username@host: [jobs] [git] workdir % 
  # * hostname color is based on hostname characters. When using as root, the 
  # prompt shows only the hostname in red color.
  # * [jobs], if applicable, counts the number of suspended jobs tty
  # * [git], if applicable, represents the status of your git repo (more on that
  # later)
  # * '%' prompt will be green if last command return value is 0, yellow otherwise.
  # 
  # git prompt is inspired by official git contrib prompt: 
  # https://github.com/git/git/tree/master/contrib/completion/git-prompt.sh
  # and it adds:
  # * the current branch
  # * '%' if there are untracked files
  # * '$' if there are stashed changes
  # * '*' if there are modified files
  # * '+' if there are added files
  # * '<' if local repo is behind remote repo
  # * '>' if local repo is ahead remote repo
  # * '=' if local repo is equal to remote repo (in sync)
  # * '<>' if local repo is diverged
  
  local green="%{$fg_bold[green]%}"
  local red="%{$fg_bold[red]%}"
  local cyan="%{$fg_bold[cyan]%}"
  local yellow="%{$fg_bold[yellow]%}"
  local blue="%{$fg_bold[blue]%}"
  local magenta="%{$fg_bold[magenta]%}"
  local white="%{$fg_bold[white]%}"
  local reset="%{$reset_color%}"
  
  local -a color_array
  color_array=($green $red $cyan $yellow $blue $magenta $white)
  
  local username_normal_color=$white
  local username_root_color=$red
  local hostname_root_color=$red
  
  # calculating hostname color with hostname characters
  for i in `hostname`; local hostname_normal_color=$color_array[$[((#i))%7+1]]
  local -a hostname_color
  hostname_color=%(!.$hostname_root_color.$hostname_normal_color)
  
  local current_dir_color=$blue
  local username_command="%n"
  local hostname_command="%m"
  local current_dir="%~"
  
  local username_output="%(!..$username_normal_color$username_command$reset@)"
  local hostname_output="$hostname_color$hostname_command$reset"
  local current_dir_output="$current_dir_color$current_dir$reset"
  local jobs_bg="${red}fg: %j$reset"
  local last_command_output="%(?.%(!.$red.$green).$yellow)"
  
  ZSH_THEME_GIT_PROMPT_PREFIX=""
093a6c34b   mj   Squashed 'repos/r...
59
  ZSH_THEME_GIT_PROMPT_SUFFIX=""
238d8e65a   mj   Squashed 'repos/r...
60
61
  ZSH_THEME_GIT_PROMPT_DIRTY=""
  ZSH_THEME_GIT_PROMPT_CLEAN=""
ed37aae5b   mj   Squashed 'repos/r...
62
63
64
65
66
  ZSH_THEME_GIT_PROMPT_UNTRACKED="$blue%%"
  ZSH_THEME_GIT_PROMPT_MODIFIED="$red*"
  ZSH_THEME_GIT_PROMPT_ADDED="$green+"
  ZSH_THEME_GIT_PROMPT_STASHED="$blue$"
  ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="$green="
238d8e65a   mj   Squashed 'repos/r...
67
68
  ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
  ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
ed37aae5b   mj   Squashed 'repos/r...
69
  ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="$red<>"
093a6c34b   mj   Squashed 'repos/r...
70

238d8e65a   mj   Squashed 'repos/r...
71
  PROMPT='$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)'
ed37aae5b   mj   Squashed 'repos/r...
72
73
  GIT_PROMPT='$(out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status);if [[ -n $out ]]; then printf %s " $white($green$out$white)$reset";fi)'
  PROMPT+="$GIT_PROMPT"
238d8e65a   mj   Squashed 'repos/r...
74
75
  PROMPT+=" $last_command_output%#$reset "
  RPROMPT=''