gnzh.zsh-theme 1.3 KB

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