]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/themes/essembeh.zsh-theme
initial
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / themes / essembeh.zsh-theme
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 ZSH_THEME_GIT_PROMPT_UNTRACKED="%%"
15 ZSH_THEME_GIT_PROMPT_ADDED="+"
16 ZSH_THEME_GIT_PROMPT_MODIFIED="*"
17 ZSH_THEME_GIT_PROMPT_RENAMED="~"
18 ZSH_THEME_GIT_PROMPT_DELETED="!"
19 ZSH_THEME_GIT_PROMPT_UNMERGED="?"
20
21 function zsh_essembeh_gitstatus {
22         ref=$(git symbolic-ref HEAD 2> /dev/null) || return
23         GIT_STATUS=$(git_prompt_status)
24         if [[ -n $GIT_STATUS ]]; then
25                 GIT_STATUS=" $GIT_STATUS"
26         fi
27         echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$GIT_STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
28 }
29
30 # by default, use green for user@host and no prefix
31 local ZSH_ESSEMBEH_COLOR="green"
32 local ZSH_ESSEMBEH_PREFIX=""
33 if [[ -n "$SSH_CONNECTION" ]]; then
34         # display the source address if connected via ssh
35         ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[$(echo $SSH_CONNECTION | awk '{print $1}')]%{$reset_color%} "
36         # use red color to highlight a remote connection
37         ZSH_ESSEMBEH_COLOR="red"
38 elif [[ -r /etc/debian_chroot ]]; then 
39         # prefix prompt in case of chroot
40         ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[chroot:$(cat /etc/debian_chroot)]%{$reset_color%} "
41 elif [[ -r /.dockerenv ]]; then
42         # also prefix prompt inside a docker container
43         ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[docker]%{$reset_color%} "
44 fi
45 if [[ $UID = 0 ]]; then
46         # always use magenta for root sessions, even in ssh
47         ZSH_ESSEMBEH_COLOR="magenta"
48 fi
49 PROMPT='${ZSH_ESSEMBEH_PREFIX}%{$fg[$ZSH_ESSEMBEH_COLOR]%}%n@%M%{$reset_color%}:%{%B$fg[yellow]%}%~%{$reset_color%b%} $(zsh_essembeh_gitstatus)%(!.#.$) '
50 RPROMPT="%(?..%{$fg[red]%}%?%{$reset_color%})"