essembeh.zsh-theme 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # My custom theme:
  2. # - single line
  3. # - quite simple by default: user@host:$PWD
  4. # - green for local shell as non root
  5. # - red for ssh shell as non root
  6. # - magenta for root sessions
  7. # - prefix with remote address for ssh shells
  8. # - prefix to detect docker containers or chroot
  9. # - git plugin to display current branch and status
  10. # git plugin
  11. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}("
  12. ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"
  13. # by default, use green for user@host and no prefix
  14. local ZSH_ESSEMBEH_COLOR="green"
  15. local ZSH_ESSEMBEH_PREFIX=""
  16. if [[ -n "$SSH_CONNECTION" ]]; then
  17. # display the source address if connected via ssh
  18. ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[$(echo $SSH_CONNECTION | awk '{print $1}')]%{$reset_color%} "
  19. # use red color to highlight a remote connection
  20. ZSH_ESSEMBEH_COLOR="red"
  21. elif [[ -r /etc/debian_chroot ]]; then
  22. # prefix prompt in case of chroot
  23. ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[chroot:$(cat /etc/debian_chroot)]%{$reset_color%} "
  24. elif [[ -r /.dockerenv ]]; then
  25. # also prefix prompt inside a docker container
  26. ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[docker]%{$reset_color%} "
  27. fi
  28. if [[ $UID = 0 ]]; then
  29. # always use magenta for root sessions, even in ssh
  30. ZSH_ESSEMBEH_COLOR="magenta"
  31. fi
  32. PROMPT='${ZSH_ESSEMBEH_PREFIX}%{$fg[$ZSH_ESSEMBEH_COLOR]%}%n@%M%{$reset_color%}:%{%B$fg[yellow]%}%~%{$reset_color%b%} $(git_prompt_info)%(!.#.$) '
  33. RPROMPT="%(?..%{$fg[red]%}%?%{$reset_color%})"