diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2017-02-14 05:50:37 +0300 |
---|---|---|
committer | Ben Hilburn <bhilburn@gmail.com> | 2017-02-14 05:50:37 +0300 |
commit | f68e055f3bf0403cb4c4a9b3b79adb8471fe3872 (patch) | |
tree | b353528a3a963527872e0e1f0dc4abbed049366b /powerlevel9k.zsh-theme | |
parent | 5957aef79ae2747e54babb7d65f99df88f63ec42 (diff) |
Merging the `ssh` detection into `context` segment, resolving conflicts.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b1de8f84..49fdaf09 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -537,26 +537,27 @@ prompt_public_ip() { # Context: user@hostname (who am I and where am I) # Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_ALWAYS_SHOW_CONTEXT false +set_default POWERLEVEL9K_CONTEXT_HOST_DEPTH "%m" prompt_context() { local current_state="DEFAULT" - declare -A context_states + typeset -AH context_states context_states=( "ROOT" "yellow" "DEFAULT" "011" ) + local content="$USER" - if [[ "$USER" != "$DEFAULT_USER" ]]; then - if [[ $(print -P "%#") == '#' ]]; then - 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" + + if [[ "POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + + if [[ $(print -P "%#") == '#' ]]; then + current_state="ROOT" fi - else - content="${content}@%m" - fi - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" + + content="${content}@${POWERLEVEL9K_CONTEXT_HOST_DEPTH}" + + "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" fi } @@ -704,13 +705,6 @@ prompt_history() { "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" '%h' } -prompt_detect_ssh(){ - local color="yellow" - if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "$color" "ssh" - fi -} - # Detection for virtualization (systemd based systems only) prompt_detect_virt() { if ! command -v systemd-detect-virt;then |