michelebologna.zsh-theme 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. local green="%{$fg_bold[green]%}"
  26. local red="%{$fg_bold[red]%}"
  27. local cyan="%{$fg_bold[cyan]%}"
  28. local yellow="%{$fg_bold[yellow]%}"
  29. local blue="%{$fg_bold[blue]%}"
  30. local magenta="%{$fg_bold[magenta]%}"
  31. local white="%{$fg_bold[white]%}"
  32. local reset="%{$reset_color%}"
  33. local -a color_array
  34. color_array=($green $red $cyan $yellow $blue $magenta $white)
  35. local username_normal_color=$white
  36. local username_root_color=$red
  37. local hostname_root_color=$red
  38. # calculating hostname color with hostname characters
  39. for i in `hostname`; local hostname_normal_color=$color_array[$[((#i))%7+1]]
  40. local -a hostname_color
  41. hostname_color=%(!.$hostname_root_color.$hostname_normal_color)
  42. local current_dir_color=$blue
  43. local username_command="%n"
  44. local hostname_command="%m"
  45. local current_dir="%~"
  46. local username_output="%(!..$username_normal_color$username_command$reset@)"
  47. local hostname_output="$hostname_color$hostname_command$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. ZSH_THEME_GIT_PROMPT_PREFIX=""
  52. ZSH_THEME_GIT_PROMPT_SUFFIX=""
  53. ZSH_THEME_GIT_PROMPT_DIRTY=""
  54. ZSH_THEME_GIT_PROMPT_CLEAN=""
  55. ZSH_THEME_GIT_PROMPT_UNTRACKED="$blue%%"
  56. ZSH_THEME_GIT_PROMPT_MODIFIED="$red*"
  57. ZSH_THEME_GIT_PROMPT_ADDED="$green+"
  58. ZSH_THEME_GIT_PROMPT_STASHED="$blue$"
  59. ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="$green="
  60. ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
  61. ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
  62. ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="$red<>"
  63. PROMPT='$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)'
  64. GIT_PROMPT='$(out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status);if [[ -n $out ]]; then printf %s " $white($green$out$white)$reset";fi)'
  65. PROMPT+="$GIT_PROMPT"
  66. PROMPT+=" $last_command_output%#$reset "
  67. RPROMPT=''