From a66aaf2edd703304b7273fd387091f48a1effad8 Mon Sep 17 00:00:00 2001 From: Rishi K Date: Mon, 17 Jan 2022 15:50:00 +0530 Subject: [PATCH] perf: use string manipulation to extract exact error message in Clean-Log feature Use string manipulation to extract the main message from builtin cd error in Clean-Log feature. --- feats/hist-dir.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/feats/hist-dir.sh b/feats/hist-dir.sh index 8a0509b..011990a 100644 --- a/feats/hist-dir.sh +++ b/feats/hist-dir.sh @@ -48,9 +48,13 @@ __smartcd::clean_log() { printf '%s\n' "${_path}" >> "${valid_paths}" else if [[ ${smartcd_current_shell} = "zsh" ]]; then - printf '%s\n' "${_path} ${colr_red}$( printf '%s\n' "${_cd_error}" | __smartcd::col_n 6 ":" )${colr_reset}" + _cd_error=${_cd_error##*::} + _cd_error=${_cd_error#* } + _cd_error=${_cd_error%:*} + printf '%s\n' "${_path} ${colr_red}${_cd_error}${colr_reset}" else - printf '%s\n' "${_path} ${colr_red}$( printf '%s\n' "${_cd_error}" | __smartcd::col_n 4 ":" )${colr_reset}" + _cd_error=${_cd_error##*:} + printf '%s\n' "${_path} ${colr_red}${_cd_error}${colr_reset}" fi fi fi