gnzh.zsh-theme 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png
  2. # Based on bira theme
  3. # load some modules
  4. autoload -U colors zsh/terminfo # Used in the colour alias below
  5. colors
  6. setopt prompt_subst
  7. # make some aliases for the colours: (could use normal escape sequences too)
  8. for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
  9. eval PR_$color='%{$fg[${(L)color}]%}'
  10. done
  11. eval PR_NO_COLOR="%{$terminfo[sgr0]%}"
  12. eval PR_BOLD="%{$terminfo[bold]%}"
  13. # Check the UID
  14. if [[ $UID -ne 0 ]]; then # normal user
  15. eval PR_USER='${PR_GREEN}%n${PR_NO_COLOR}'
  16. eval PR_USER_OP='${PR_GREEN}%#${PR_NO_COLOR}'
  17. local PR_PROMPT='$PR_NO_COLOR➤ $PR_NO_COLOR'
  18. else # root
  19. eval PR_USER='${PR_RED}%n${PR_NO_COLOR}'
  20. eval PR_USER_OP='${PR_RED}%#${PR_NO_COLOR}'
  21. local PR_PROMPT='$PR_RED➤ $PR_NO_COLOR'
  22. fi
  23. # Check if we are on SSH or not
  24. if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
  25. eval PR_HOST='${PR_YELLOW}%M${PR_NO_COLOR}' #SSH
  26. else
  27. eval PR_HOST='${PR_GREEN}%M${PR_NO_COLOR}' # no SSH
  28. fi
  29. local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})"
  30. local user_host='${PR_USER}${PR_CYAN}@${PR_HOST}'
  31. local current_dir='%{$PR_BOLD$PR_BLUE%}%~%{$PR_NO_COLOR%}'
  32. local rvm_ruby=''
  33. if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect local user rvm installation
  34. rvm_ruby='%{$PR_RED%}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%{$PR_NO_COLOR%}'
  35. elif which rvm-prompt &> /dev/null; then # detect sysem-wide rvm installation
  36. rvm_ruby='%{$PR_RED%}‹$(rvm-prompt i v g s)›%{$PR_NO_COLOR%}'
  37. elif which rbenv &> /dev/null; then # detect Simple Ruby Version management
  38. rvm_ruby='%{$PR_RED%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$PR_NO_COLOR%}'
  39. fi
  40. local git_branch='$(git_prompt_info)%{$PR_NO_COLOR%}'
  41. #PROMPT="${user_host} ${current_dir} ${rvm_ruby} ${git_branch}$PR_PROMPT "
  42. PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
  43. ╰─$PR_PROMPT "
  44. RPS1="${return_code}"
  45. ZSH_THEME_GIT_PROMPT_PREFIX="%{$PR_YELLOW%}‹"
  46. ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$PR_NO_COLOR%}"