Not for normies
| 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 | |
| 11 | # git plugin |
| 12 | ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}(" |
| 13 | ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}" |
| 14 | |
| 15 | |
| 16 | # by default, use green for user@host and no prefix |
| 17 | local ZSH_ESSEMBEH_COLOR="green" |
| 18 | local ZSH_ESSEMBEH_PREFIX="" |
| 19 | if [[ -n "$SSH_CONNECTION" ]]; then |
| 20 | # display the source address if connected via ssh |
| 21 | ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[$(echo $SSH_CONNECTION | awk '{print $1}')]%{$reset_color%} " |
| 22 | # use red color to highlight a remote connection |
| 23 | ZSH_ESSEMBEH_COLOR="red" |
| 24 | elif [[ -r /etc/debian_chroot ]]; then |
| 25 | # prefix prompt in case of chroot |
| 26 | ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[chroot:$(cat /etc/debian_chroot)]%{$reset_color%} " |
| 27 | elif [[ -r /.dockerenv ]]; then |
| 28 | # also prefix prompt inside a docker container |
| 29 | ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[docker]%{$reset_color%} " |
| 30 | fi |
| 31 | if [[ $UID = 0 ]]; then |
| 32 | # always use magenta for root sessions, even in ssh |
| 33 | ZSH_ESSEMBEH_COLOR="magenta" |
| 34 | fi |
| 35 | PROMPT='${ZSH_ESSEMBEH_PREFIX}%{$fg[$ZSH_ESSEMBEH_COLOR]%}%n@%M%{$reset_color%}:%{%B$fg[yellow]%}%~%{$reset_color%b%} $(git_prompt_info)%(!.#.$) ' |
| 36 | RPROMPT="%(?..%{$fg[red]%}%?%{$reset_color%})" |