gnzh.zsh-theme 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png
  2. # Based on bira theme
  3. setopt prompt_subst
  4. () {
  5. local PR_USER PR_USER_OP PR_PROMPT PR_HOST
  6. # Check the UID
  7. if [[ $UID -ne 0 ]]; then # normal user
  8. PR_USER='%F{green}%n%f'
  9. PR_USER_OP='%F{green}%#%f'
  10. PR_PROMPT='%f➤ %f'
  11. else # root
  12. PR_USER='%F{red}%n%f'
  13. PR_USER_OP='%F{red}%#%f'
  14. PR_PROMPT='%F{red}➤ %f'
  15. fi
  16. # Check if we are on SSH or not
  17. if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
  18. PR_HOST='%F{red}%M%f' # SSH
  19. else
  20. PR_HOST='%F{green}%M%f' # no SSH
  21. fi
  22. local return_code="%(?..%F{red}%? ↵%f)"
  23. local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
  24. local current_dir="%B%F{blue}%~%f%b"
  25. local rvm_ruby=''
  26. if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
  27. rvm_ruby='%F{red}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%f'
  28. elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation
  29. rvm_ruby='%F{red}‹$(rvm-prompt i v g s)›%f'
  30. elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management
  31. rvm_ruby='%F{red}‹$(rbenv version | sed -e "s/ (set.*$//")›%f'
  32. fi
  33. local git_branch='$(git_prompt_info)'
  34. PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
  35. ╰─$PR_PROMPT "
  36. RPROMPT="${return_code}"
  37. ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹"
  38. ZSH_THEME_GIT_PROMPT_SUFFIX="› %f"
  39. }