summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2015-07-25 02:34:11 +0300
committerDominik Ritter <dritter03@googlemail.com>2015-07-25 02:34:11 +0300
commit2bc3b09963f34e3f404556100f28b4bf4e904a92 (patch)
tree94db151a32263ea05a12e2131601c303da216a4d /powerlevel9k.zsh-theme
parent925e6752f7261efb031c333e6c1206093760a321 (diff)
Implemented different ways to truncate the directory path.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rw-r--r--powerlevel9k.zsh-theme15
1 files changed, 13 insertions, 2 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 69eee6e3..3e793d7e 100644
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -450,8 +450,19 @@ prompt_context() {
prompt_dir() {
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"
+
+ case "$POWERLEVEL9K_SHORTEN_STRATEGY" in
+ complete_directories)
+ current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:.../:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c"
+ ;;
+ truncate_from_right)
+ current_path=$(pwd | sed -e "s,^$HOME,~," | sed -E "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1\//g")
+ ;;
+ *)
+ current_path=$(pwd | sed -e "s,^$HOME,~," | sed -E "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1\.\.\2\//g")
+ ;;
+ esac
+
fi
$1_prompt_segment "$0" "blue" "$DEFAULT_COLOR" "$current_path"