1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-14 00:50:08 +00:00

Merge pull request #709 from tippl/next

Add remote state to context prompt
This commit is contained in:
Ben Hilburn 2017-12-29 14:39:13 -05:00 committed by GitHub
commit 200089a91f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -571,24 +571,25 @@ prompt_context() {
context_states=(
"ROOT" "yellow"
"DEFAULT" "yellow"
"REMOTE" "yellow"
)
local content=""
if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
if [[ $(print -P "%#") == '#' ]]; then
current_state="ROOT"
fi
content="${POWERLEVEL9K_CONTEXT_TEMPLATE}"
elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then
content="$(whoami)"
else
return
fi
if [[ $(print -P "%#") == '#' ]]; then
current_state="ROOT"
elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
current_state="REMOTE"
fi
"$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}"
}