aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorChristian Rebischke <Chris.Rebischke@posteo.de>2016-12-11 06:39:45 +0300
committerChristian Rebischke <Chris.Rebischke@posteo.de>2016-12-18 23:08:43 +0300
commit30076080a734c0bff552293b8b2d4e7c69019c03 (patch)
treecc64b16e4d80bb437d82007b6b4342ce71560fbf /powerlevel9k.zsh-theme
parent202ab1500727e4f37545eaff849d4f9a52b823c4 (diff)
added ssh support and POWERLEVEL9K_HIDE_HOST feature
refactorized the sourcecode added true/false switch
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme20
1 files changed, 16 insertions, 4 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index c4b24b55..f2262994 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -434,13 +434,25 @@ prompt_battery() {
# Context: user@hostname (who am I and where am I)
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
prompt_context() {
- if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
+ local current_state="DEFAULT"
+ declare -A context_states
+ context_states=(
+ "ROOT" "yellow"
+ "DEFAULT" "011"
+ )
+ local content="$USER"
+ if [[ "$USER" != "$DEFAULT_USER" ]]; then
if [[ $(print -P "%#") == '#' ]]; then
- # Shell runs as root
- "$1_prompt_segment" "$0_ROOT" "$2" "$DEFAULT_COLOR" "yellow" "$USER@%m"
+ current_state="ROOT"
+ fi
+ if [[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]]; then
+ if [[ "$POWERLEVEL9K_HIDE_HOST" == "false" || -z "$POWERLEVEL9K_HIDE_HOST" ]]; then
+ content="${content}@%m"
+ fi
else
- "$1_prompt_segment" "$0_DEFAULT" "$2" "$DEFAULT_COLOR" "011" "$USER@%m"
+ content="${content}@%m"
fi
+ "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}"
fi
}