diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2017-05-23 04:46:17 +0300 |
---|---|---|
committer | Ben Hilburn <bhilburn@gmail.com> | 2017-05-23 04:46:17 +0300 |
commit | 44764285c31b9355078c955a747f2189acae964d (patch) | |
tree | e49c1d18a86c93486654514f0a42c8fe85841ae3 /powerlevel9k.zsh-theme | |
parent | 643e8372db1d5168a6651b982e5c9f5347f9910a (diff) | |
parent | 61790bf24213f1fb8b98d853e47a37a1a75d3a10 (diff) |
Merge branch 'host_user' of https://github.com/onaforeignshore/powerlevel9k into onaforeignshore-host_user
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c2696669..20bc9d2b 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -604,6 +604,61 @@ prompt_context() { "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" } +################################################################ +# User: user (who am I) +# Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_USER_TEMPLATE "%n" +prompt_user() { + local current_state="DEFAULT" + typeset -AH user_state + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if [[ $(print -P "%#") == '#' ]]; then + user_state=( + "STATE" "ROOT" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "ROOT_ICON" + ) + else + user_state=( + "STATE" "DEFAULT" + "CONTENT" "$USER" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "011" + "VISUAL_IDENTIFIER" "USER_ICON" + ) + fi + fi + "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" +} + +################################################################ +# Host: machine (where am I) +set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +prompt_host() { + local current_state="LOCAL" + typeset -AH host_state + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + host_state=( + "STATE" "REMOTE" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SSH_ICON" + ) + else + host_state=( + "STATE" "LOCAL" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "011" + "VISUAL_IDENTIFIER" "HOST_ICON" + ) + fi + "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" +} + # The 'custom` prompt provides a way for users to invoke commands and display # the output in a segment. prompt_custom() { |