ys.zsh-theme 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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=" %{$reset_color%}on%{$fg[blue]%} "
  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. # SVN info
  20. local svn_info='$(svn_prompt_info)'
  21. ZSH_THEME_SVN_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}svn${YS_VCS_PROMPT_PREFIX2}"
  22. ZSH_THEME_SVN_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
  23. ZSH_THEME_SVN_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
  24. ZSH_THEME_SVN_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
  25. # HG info
  26. local hg_info='$(ys_hg_prompt_info)'
  27. ys_hg_prompt_info() {
  28. # make sure this is a hg dir
  29. if [ -d '.hg' ]; then
  30. echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}"
  31. echo -n $(hg branch 2>/dev/null)
  32. if [[ "$(hg config oh-my-zsh.hide-dirty 2>/dev/null)" != "1" ]]; then
  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. fi
  39. echo -n "$YS_VCS_PROMPT_SUFFIX"
  40. fi
  41. }
  42. # Virtualenv
  43. local venv_info='$(virtenv_prompt)'
  44. YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}"
  45. YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
  46. virtenv_prompt() {
  47. [[ -n ${VIRTUAL_ENV} ]] || return
  48. echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
  49. }
  50. local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
  51. # Prompt format:
  52. #
  53. # PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] C:LAST_EXIT_CODE
  54. # $ COMMAND
  55. #
  56. # For example:
  57. #
  58. # % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] C:0
  59. # $
  60. PROMPT="
  61. %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
  62. %(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
  63. %{$reset_color%}@ \
  64. %{$fg[green]%}%m \
  65. %{$reset_color%}in \
  66. %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
  67. ${hg_info}\
  68. ${git_info}\
  69. ${svn_info}\
  70. ${venv_info}\
  71. \
  72. [%*] $exit_code
  73. %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"