From 2fdbd6158c78a0b1786d6a030629fe3a930fc46d Mon Sep 17 00:00:00 2001 From: Niklas Heer Date: Wed, 30 Dec 2015 15:49:23 +0100 Subject: [PATCH 1/5] added fishe-like shortening strategy --- powerlevel9k.zsh-theme | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 19c5ea98..eed524ae 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -414,6 +414,9 @@ prompt_dir() { truncate_from_right) current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1..\//g") ;; + truncate_fish_like) + current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1\//g") + ;; *) current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:.../:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c" ;; From f472ba7341615f17b279cc6859535e6e7668f637 Mon Sep 17 00:00:00 2001 From: Niklas Heer Date: Thu, 31 Dec 2015 15:57:56 +0100 Subject: [PATCH 2/5] added a new variable POWERLEVEL9K_SHORTEN_DELIMITER to specifiy the delimiter --- powerlevel9k.zsh-theme | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index eed524ae..7f578223 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -407,18 +407,23 @@ prompt_dir() { local current_path='%~' if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" ]]; then + if [ -z "$POWERLEVEL9K_SHORTEN_DELIMITER" ] + then + POWERLEVEL9K_SHORTEN_DELIMITER=".." + elif [ "$POWERLEVEL9K_SHORTEN_DELIMITER" = false ] + then + POWERLEVEL9K_SHORTEN_DELIMITER="" + fi + case "$POWERLEVEL9K_SHORTEN_STRATEGY" in truncate_middle) - current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1\.\.\2\//g") + current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g") ;; truncate_from_right) - current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1..\//g") - ;; - truncate_fish_like) - current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1\//g") + current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\//g") ;; *) - current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:.../:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c" + current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c" ;; esac From 3441f750bf114bc68e519d9ab351373b54e83d7c Mon Sep 17 00:00:00 2001 From: Niklas Heer Date: Thu, 31 Dec 2015 19:04:26 +0100 Subject: [PATCH 3/5] used set_default-function instead --- powerlevel9k.zsh-theme | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7f578223..706c198a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -407,13 +407,7 @@ prompt_dir() { local current_path='%~' if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" ]]; then - if [ -z "$POWERLEVEL9K_SHORTEN_DELIMITER" ] - then - POWERLEVEL9K_SHORTEN_DELIMITER=".." - elif [ "$POWERLEVEL9K_SHORTEN_DELIMITER" = false ] - then - POWERLEVEL9K_SHORTEN_DELIMITER="" - fi + set_default POWERLEVEL9K_SHORTEN_DELIMITER ".." case "$POWERLEVEL9K_SHORTEN_STRATEGY" in truncate_middle) From a7bedd5320f0d6fba5d4179aace5ead1f42c459d Mon Sep 17 00:00:00 2001 From: Niklas Heer Date: Mon, 4 Jan 2016 19:00:02 +0100 Subject: [PATCH 4/5] added documentation --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index c611c5d9..e92f29ae 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,20 @@ To change the way how the current working directory is truncated, just set: POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" # default behaviour is to truncate whole directories +You can also change the delimiter (the dots in between) which is used to truncate the working directory. This setting is optional. The default are 2 dots. + + # set the delimiter to an empty string to hide it + POWERLEVEL9K_SHORTEN_DELIMITER="" + # or set it to anything else you want (e.g. 3 dots) + POWERLEVEL9K_SHORTEN_DELIMITER="..." + +With this you could achive the truncate behaviour of the fish shell. Which turncates `/usr/share/plasma` to `/u/s/plasma` + + POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + POWERLEVEL9K_SHORTEN_DELIMITER="" + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" + + In each case you have to specify the length you want to shorten the directory to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in others whole directories. From e7e11d5ec87f30323d065100c1e8fdb4a98c3aba Mon Sep 17 00:00:00 2001 From: Niklas Heer Date: Mon, 4 Jan 2016 19:26:25 +0100 Subject: [PATCH 5/5] fixed documentation --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e92f29ae..a6b69bff 100644 --- a/README.md +++ b/README.md @@ -207,17 +207,16 @@ To change the way how the current working directory is truncated, just set: You can also change the delimiter (the dots in between) which is used to truncate the working directory. This setting is optional. The default are 2 dots. - # set the delimiter to an empty string to hide it + # set the delimiter to an empty string to hide it POWERLEVEL9K_SHORTEN_DELIMITER="" # or set it to anything else you want (e.g. 3 dots) POWERLEVEL9K_SHORTEN_DELIMITER="..." With this you could achive the truncate behaviour of the fish shell. Which turncates `/usr/share/plasma` to `/u/s/plasma` - POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 - POWERLEVEL9K_SHORTEN_DELIMITER="" - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" - + POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + POWERLEVEL9K_SHORTEN_DELIMITER="" + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" In each case you have to specify the length you want to shorten the directory to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in