mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
added ssh support and POWERLEVEL9K_HIDE_HOST feature
refactorized the sourcecode added true/false switch
This commit is contained in:
parent
202ab15007
commit
30076080a7
2 changed files with 22 additions and 5 deletions
|
@ -241,6 +241,11 @@ elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`:
|
||||||
|----------|---------------|-------------|
|
|----------|---------------|-------------|
|
||||||
|`DEFAULT_USER`|None|Username to consider a "default context" (you can also use `$USER`)|
|
|`DEFAULT_USER`|None|Username to consider a "default context" (you can also use `$USER`)|
|
||||||
|
|
||||||
|
You can use POWERLEVEL9K_HIDE_HOST for hiding the hostname in the prompt
|
||||||
|
when you are not in a ssh session. For example:
|
||||||
|
|
||||||
|
POWERLEVEL9K_HIDE_HOST="yes"
|
||||||
|
|
||||||
##### dir
|
##### dir
|
||||||
|
|
||||||
The `dir` segment shows the current working directory. When using the "Awesome
|
The `dir` segment shows the current working directory. When using the "Awesome
|
||||||
|
|
|
@ -434,13 +434,25 @@ prompt_battery() {
|
||||||
# Context: user@hostname (who am I and where am I)
|
# Context: user@hostname (who am I and where am I)
|
||||||
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
|
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
|
||||||
prompt_context() {
|
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
|
if [[ $(print -P "%#") == '#' ]]; then
|
||||||
# Shell runs as root
|
current_state="ROOT"
|
||||||
"$1_prompt_segment" "$0_ROOT" "$2" "$DEFAULT_COLOR" "yellow" "$USER@%m"
|
|
||||||
else
|
|
||||||
"$1_prompt_segment" "$0_DEFAULT" "$2" "$DEFAULT_COLOR" "011" "$USER@%m"
|
|
||||||
fi
|
fi
|
||||||
|
if [[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]]; then
|
||||||
|
if [[ "$POWERLEVEL9K_HIDE_HOST" == "false" || -z "$POWERLEVEL9K_HIDE_HOST" ]]; then
|
||||||
|
content="${content}@%m"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
content="${content}@%m"
|
||||||
|
fi
|
||||||
|
"$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue