summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2017-01-04 01:23:09 +0300
committerGitHub <noreply@github.com>2017-01-04 01:23:09 +0300
commitc5909e71ea873542a053531012ee62a5af3a57b8 (patch)
treec27b772d54308c8872149c58330a13a692d80862
parentc86b4009ce09b1d2f274579373fa53648fd1b362 (diff)
parent37145ef14d854bfb7ca65145e9bd86cefcfba060 (diff)
Merge pull request #369 from rjorgenson/context_host_depth
Context host depth
-rw-r--r--README.md8
-rwxr-xr-xpowerlevel9k.zsh-theme5
2 files changed, 11 insertions, 2 deletions
diff --git a/README.md b/README.md
index ef3207ac..54b5c519 100644
--- a/README.md
+++ b/README.md
@@ -240,9 +240,17 @@ it, but only display it if you are not your normal user or on a remote host
To use this feature, make sure the `context` segment is enabled in your prompt
elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`:
+You can set the `POWERLEVEL9K_CONTEXT_HOST_DEPTH` variable to change how the
+hostname is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information]
+for details. Default is set to %m which will show the hostname up to the first ‘.’
+You can set it to %{N}m where N is an integer to show that many segments of system
+hostname. Setting N to a negative integer will show that many segments from the
+end of the hostname.
+
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`DEFAULT_USER`|None|Username to consider a "default context" (you can also use `$USER`)|
+|`POWERLEVEL9K_CONTEXT_HOST_DEPTH`|%m|Customizable host depth on prompt|
##### dir
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 9ea12aa7..9e89f68d 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -429,12 +429,13 @@ 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() {
+ set_default POWERLEVEL9K_CONTEXT_HOST_DEPTH "%m"
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
if [[ $(print -P "%#") == '#' ]]; then
# Shell runs as root
- "$1_prompt_segment" "$0_ROOT" "$2" "$DEFAULT_COLOR" "yellow" "$USER@%m"
+ "$1_prompt_segment" "$0_ROOT" "$2" "$DEFAULT_COLOR" "yellow" "$USER@$POWERLEVEL9K_CONTEXT_HOST_DEPTH"
else
- "$1_prompt_segment" "$0_DEFAULT" "$2" "$DEFAULT_COLOR" "011" "$USER@%m"
+ "$1_prompt_segment" "$0_DEFAULT" "$2" "$DEFAULT_COLOR" "011" "$USER@$POWERLEVEL9K_CONTEXT_HOST_DEPTH"
fi
fi
}