ys.zsh-theme 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.
  4. # Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
  5. #
  6. # Mar 2013 Yad Smood
  7. # VCS
  8. YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
  9. YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
  10. YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
  11. YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
  12. YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o"
  13. # Git info
  14. local git_info='$(git_prompt_info)'
  15. ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}"
  16. ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
  17. ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
  18. ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
  19. # HG info
  20. local hg_info='$(ys_hg_prompt_info)'
  21. ys_hg_prompt_info() {
  22. # make sure this is a hg dir
  23. if [ -d '.hg' ]; then
  24. echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}"
  25. echo -n $(hg branch 2>/dev/null)
  26. if [ -n "$(hg status 2>/dev/null)" ]; then
  27. echo -n "$YS_VCS_PROMPT_DIRTY"
  28. else
  29. echo -n "$YS_VCS_PROMPT_CLEAN"
  30. fi
  31. echo -n "$YS_VCS_PROMPT_SUFFIX"
  32. fi
  33. }
  34. local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
  35. # Prompt format:
  36. #
  37. # PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] C:LAST_EXIT_CODE
  38. # $ COMMAND
  39. #
  40. # For example:
  41. #
  42. # % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] C:0
  43. # $
  44. PROMPT="
  45. %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
  46. %(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
  47. %{$fg[white]%}@ \
  48. %{$fg[green]%}%m \
  49. %{$fg[white]%}in \
  50. %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
  51. ${hg_info}\
  52. ${git_info}\
  53. \
  54. %{$fg[white]%}[%*] $exit_code
  55. %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"