aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--powerlevel9k.zsh-theme8
2 files changed, 15 insertions, 1 deletions
diff --git a/README.md b/README.md
index e4cacfb1..42c6c9a0 100644
--- a/README.md
+++ b/README.md
@@ -260,6 +260,14 @@ elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`:
export DEFAULT_USER=<your username>
+#### The `dir` segment
+
+The `dir` segment shows the current working directory. You can limit the output
+to a certain length:
+
+ # Limit to the last two folders
+ POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
+
#### The 'time' segment
By default the time is show in 'H:M:S' format. If you want to change it,
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index cecb19db..4f75e89b 100644
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -443,7 +443,13 @@ prompt_context() {
# Dir: current working directory
prompt_dir() {
- $1_prompt_segment "$0" "blue" "$DEFAULT_COLOR" '%~'
+ local current_path='%~'
+ if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" ]]; then
+ # shorten path to $POWERLEVEL9K_SHORTEN_DIR_LENGTH
+ current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:.../:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c"
+ fi
+
+ $1_prompt_segment "$0" "blue" "$DEFAULT_COLOR" "$current_path"
}
# Command number (in local history)