From 94c13536da2a11b52022c2cf110195dfbd040d3a Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Thu, 4 Feb 2021 15:36:54 -0800 Subject: [PATCH] Minor edits to PWD --- functions/_tide_item_pwd.fish | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/functions/_tide_item_pwd.fish b/functions/_tide_item_pwd.fish index 9812ec1..b592bba 100644 --- a/functions/_tide_item_pwd.fish +++ b/functions/_tide_item_pwd.fish @@ -15,20 +15,18 @@ function _tide_item_pwd set -l i 0 for unusedVariable in $splitPwd - set i (math $i + 1) # This keeps us from using seq + set -l parentDir (string join -- '/' $splitPwd[1..$i] | string replace '~' $HOME) # Use i from before increment - set -l parentDir (string join -- '/' $splitPwd[1..(math $i-1)] | string replace '~' $HOME) + set i (math $i + 1) # This keeps us from using seq # Returns true if any markers exist in splitPwd[$i], or if anchorDirs contains i if test -z false (string split -m 2 " " -- "-o -e "$parentDir/$tide_pwd_markers) || contains $i $anchorDirs set splitPwdForOutput[$i] $colorAnchors$splitPwd[$i]$keepBackgroundColor$colorDirs else if test (string join -- '/' $splitPwdForLength | string length) -gt $pwdMaxLength - set -l truncationLength 1 - while set -l truncated (string sub --length $truncationLength -- $splitPwd[$i]) && - test (string length -- $truncated) -lt (string length -- $splitPwdForLength[$i]) && + while set -l truncationLength (math $truncationLength + 1) && + test $truncationLength -lt (string length -- $splitPwdForLength[$i]) && + set -l truncated (string sub --length $truncationLength -- $splitPwd[$i]) && test (count $parentDir/$truncated*/) -gt 1 - - set truncationLength (math $truncationLength + 1) end set splitPwdForLength[$i] $truncated