From e6c37b6bc5ba26928ce75720d7fa1c2addb5ccac Mon Sep 17 00:00:00 2001 From: guixxx Date: Sun, 7 May 2017 10:34:54 -0300 Subject: Icons for Windows/Cygwin + Refixes 32-bit support --- functions/utilities.zsh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'functions/utilities.zsh') diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 86e5ba0e..9bd82060 100644 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -85,6 +85,10 @@ case $(uname) in OS='OSX' OS_ICON=$(print_icon 'APPLE_ICON') ;; + CYGWIN_NT-*) + OS='Windows' + OS_ICON=$(print_icon 'WINDOWS_ICON') + ;; FreeBSD) OS='BSD' OS_ICON=$(print_icon 'FREEBSD_ICON') -- cgit v1.2.3 From a234636982349a82ab6c7f0674f3ff884acddc94 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 12 Jul 2017 03:29:31 +0200 Subject: Fix empty delimiter Even if the delimiter is empty, the min length should be 1. This fixes #558 --- functions/utilities.zsh | 2 +- test/segments/dir.spec | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'functions/utilities.zsh') diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 86e5ba0e..39c5ecae 100644 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -212,7 +212,7 @@ function segmentShouldBeJoined() { # Given a directory path, truncate it according to the settings for # `truncate_from_right` function truncatePathFromRight() { - local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER} + local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER:-1} echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \ "s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g" } diff --git a/test/segments/dir.spec b/test/segments/dir.spec index b2991175..3a6af649 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -72,6 +72,26 @@ function testTruncationFromRightWorks() { unset POWERLEVEL9K_SHORTEN_STRATEGY } +function testTruncationFromRightWithEmptyDelimiter() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_DELIMITER="" + POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}/tmp/po/1/12/123/12/12/12/12/12/123456789 %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH + unset POWERLEVEL9K_SHORTEN_DELIMITER + unset POWERLEVEL9K_SHORTEN_STRATEGY +} + function testTruncateWithFolderMarkerWorks() { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" -- cgit v1.2.3