gnzh.zsh-theme 2.0 KB

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