ys.zsh-theme 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Clean, simple, compatible and meaningful.
  2. # Tested on Linux, Unix and Windows under ANSI colors.
  3. # It is recommended to use with a dark background and the font Inconsolata.
  4. # Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
  5. #
  6. # http://ysmood.org/wp/2013/03/my-ys-terminal-theme/
  7. # Mar 2013 ys
  8. # Machine name.
  9. function box_name {
  10. [ -f ~/.box-name ] && cat ~/.box-name || echo $HOST
  11. }
  12. # Directory info.
  13. local current_dir='${PWD/#$HOME/~}'
  14. # VCS
  15. YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
  16. YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
  17. YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
  18. YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
  19. YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o"
  20. # Git info.
  21. local git_info='$(git_prompt_info)'
  22. ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}"
  23. ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
  24. ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
  25. ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
  26. # HG info
  27. local hg_info='$(ys_hg_prompt_info)'
  28. ys_hg_prompt_info() {
  29. # make sure this is a hg dir
  30. if [ -d '.hg' ]; then
  31. echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}"
  32. echo -n $(hg branch 2>/dev/null)
  33. if [ -n "$(hg status 2>/dev/null)" ]; then
  34. echo -n "$YS_VCS_PROMPT_DIRTY"
  35. else
  36. echo -n "$YS_VCS_PROMPT_CLEAN"
  37. fi
  38. echo -n "$YS_VCS_PROMPT_SUFFIX"
  39. fi
  40. }
  41. # Prompt format: \n # USER at MACHINE in DIRECTORY on git:BRANCH STATE [TIME] \n $
  42. PROMPT="
  43. %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
  44. %{$fg[cyan]%}%n \
  45. %{$fg[white]%}at \
  46. %{$fg[green]%}$(box_name) \
  47. %{$fg[white]%}in \
  48. %{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\
  49. ${hg_info}\
  50. ${git_info} \
  51. %{$fg[white]%}[%*]
  52. %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
  53. if [[ "$USER" == "root" ]]; then
  54. PROMPT="
  55. %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
  56. %{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \
  57. %{$fg[white]%}at \
  58. %{$fg[green]%}$(box_name) \
  59. %{$fg[white]%}in \
  60. %{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\
  61. ${hg_info}\
  62. ${git_info} \
  63. %{$fg[white]%}[%*]
  64. %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
  65. fi