Parent directory

essembeh.zsh-theme

1446 bytes
 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
12ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}("
13ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"
14
15
16# by default, use green for user@host and no prefix
17local ZSH_ESSEMBEH_COLOR="green"
18local ZSH_ESSEMBEH_PREFIX=""
19if [[ -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"
24elif [[ -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%} "
27elif [[ -r /.dockerenv ]]; then
28	# also prefix prompt inside a docker container
29	ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[docker]%{$reset_color%} "
30fi
31if [[ $UID = 0 ]]; then
32	# always use magenta for root sessions, even in ssh
33	ZSH_ESSEMBEH_COLOR="magenta"
34fi
35PROMPT='${ZSH_ESSEMBEH_PREFIX}%{$fg[$ZSH_ESSEMBEH_COLOR]%}%n@%M%{$reset_color%}:%{%B$fg[yellow]%}%~%{$reset_color%b%} $(git_prompt_info)%(!.#.$) '
36RPROMPT="%(?..%{$fg[red]%}%?%{$reset_color%})"