From 9960640bed30abcfbc5484b15210e04f4c446608 Mon Sep 17 00:00:00 2001 From: Will Boyce Date: Wed, 12 Jun 2019 11:21:53 +0100 Subject: [PATCH] dir: fix tilde expansion in package_path --- segments/dir/dir.p9k | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/segments/dir/dir.p9k b/segments/dir/dir.p9k index 4986dac0d..4e4f4b06e 100644 --- a/segments/dir/dir.p9k +++ b/segments/dir/dir.p9k @@ -135,7 +135,6 @@ prompt_dir() { local -a markedFolders markedFolders=( $(__p9k_upsearch "(${(j:|:)P9K_DIR_PACKAGE_FILES})") ) local package_path="${markedFolders[1]}" - [[ ${(L)P9K_DIR_PATH_ABSOLUTE} != "true" ]] && package_path=${package_path/$HOME/"~"} # Replace the shortest possible match of the marked folder from # the current path. Remove the amount of characters up to the @@ -146,7 +145,9 @@ prompt_dir() { # Then, find the length of the package_path string, and save the # subdirectory path as a substring of the current directory's path from 0 # to the length of the package path's string - subdirectory_path=$(__p9k_truncate_path "${current_path:${#${(S%%)package_path//$~zero/}}}" $P9K_DIR_SHORTEN_LENGTH $P9K_DIR_SHORTEN_DELIMITER) + local package_trun_path="${package_path}" + [[ ${(L)P9K_DIR_PATH_ABSOLUTE} != "true" ]] && package_trunc_path=${package_path/$HOME/"~"} + subdirectory_path=$(__p9k_truncate_path "${current_path:${#${(S%%)package_trunc_path//$~zero/}}}" $P9K_DIR_SHORTEN_LENGTH $P9K_DIR_SHORTEN_DELIMITER) local pkgFile="unknown" for file in "${P9K_DIR_PACKAGE_FILES[@]}"; do