ys.zsh-theme 2.1 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.
  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 [[ "$(hg config oh-my-zsh.hide-dirty 2>/dev/null)" != "1" ]]; then
  27. if [ -n "$(hg status 2>/dev/null)" ]; then
  28. echo -n "$YS_VCS_PROMPT_DIRTY"
  29. else
  30. echo -n "$YS_VCS_PROMPT_CLEAN"
  31. fi
  32. fi
  33. echo -n "$YS_VCS_PROMPT_SUFFIX"
  34. fi
  35. }
  36. # Virtualenv
  37. local venv_info='$(virtenv_prompt)'
  38. YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}"
  39. YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
  40. virtenv_prompt() {
  41. [[ -n ${VIRTUAL_ENV} ]] || return
  42. echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
  43. }
  44. local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
  45. # Prompt format:
  46. #
  47. # PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] C:LAST_EXIT_CODE
  48. # $ COMMAND
  49. #
  50. # For example:
  51. #
  52. # % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] C:0
  53. # $
  54. PROMPT="
  55. %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
  56. %(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
  57. %{$fg[white]%}@ \
  58. %{$fg[green]%}%m \
  59. %{$fg[white]%}in \
  60. %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
  61. ${hg_info}\
  62. ${git_info}\
  63. ${venv_info}\
  64. \
  65. %{$fg[white]%}[%*] $exit_code
  66. %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"