ys.zsh-theme 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. typeset +H my_gray="$FG[247]"
  8. # VCS
  9. YS_VCS_PROMPT_PREFIX1=" %{$my_gray%}on%{$reset_color%} "
  10. YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
  11. YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
  12. YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
  13. YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o"
  14. # Git info
  15. local git_info='$(git_prompt_info)'
  16. ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}"
  17. ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
  18. ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
  19. ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
  20. # HG info
  21. local hg_info='$(ys_hg_prompt_info)'
  22. ys_hg_prompt_info() {
  23. # make sure this is a hg dir
  24. if [ -d '.hg' ]; then
  25. echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}"
  26. echo -n $(hg branch 2>/dev/null)
  27. if [[ "$(hg config oh-my-zsh.hide-dirty 2>/dev/null)" != "1" ]]; then
  28. if [ -n "$(hg status 2>/dev/null)" ]; then
  29. echo -n "$YS_VCS_PROMPT_DIRTY"
  30. else
  31. echo -n "$YS_VCS_PROMPT_CLEAN"
  32. fi
  33. fi
  34. echo -n "$YS_VCS_PROMPT_SUFFIX"
  35. fi
  36. }
  37. # Virtualenv
  38. local venv_info='$(virtenv_prompt)'
  39. YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}"
  40. YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
  41. virtenv_prompt() {
  42. [[ -n ${VIRTUAL_ENV} ]] || return
  43. echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
  44. }
  45. local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
  46. # Prompt format:
  47. #
  48. # PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] C:LAST_EXIT_CODE
  49. # $ COMMAND
  50. #
  51. # For example:
  52. #
  53. # % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] C:0
  54. # $
  55. PROMPT="
  56. %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
  57. %(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
  58. %{$my_gray%}@ \
  59. %{$fg[green]%}%m \
  60. %{$my_gray%}in \
  61. %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
  62. ${hg_info}\
  63. ${git_info}\
  64. ${venv_info}\
  65. \
  66. %{$my_gray%}[%*] $exit_code
  67. %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"