From 0d53d15143cd53db096bc0500f150d9cd3e1cd79 Mon Sep 17 00:00:00 2001 From: nojhan Date: Wed, 19 Oct 2022 17:39:26 +0200 Subject: [PATCH] fix(hist): zsh string trim --- dotmatrix.theme | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dotmatrix.theme b/dotmatrix.theme index 182342f..34f26fc 100644 --- a/dotmatrix.theme +++ b/dotmatrix.theme @@ -530,7 +530,11 @@ _lp_dotmatrix_theme_prompt() { local hist_max=$((DOTMATRIX_HISTORY_LAST_LEN-${#DOTMATRIX_HISTORY_LAST_LEN_MARK})) local hist_last=$(history | tail -n 1 | cut -d" " -f5-) if [[ ${#hist_last} -gt $hist_max ]] ; then - hist_last="${hist_last:0:$hist_max}${DOTMATRIX_HISTORY_LAST_LEN_MARK}" + if (( _LP_SHELL_zsh )) ; then + hist_last="${hist_last[1,$hist_max]}${DOTMATRIX_HISTORY_LAST_LEN_MARK}" + else # bash + hist_last="${hist_last:0:$hist_max}${DOTMATRIX_HISTORY_LAST_LEN_MARK}" + fi fi local hist_most=$(history | tail -n ${DOTMATRIX_HISTORY_MOST_BACK} | awk '{print $4}' | sort | uniq --count | sort --numeric-sort --reverse | head -n 1 | awk '{print $2}') inline_right="$d${hist_last}$I${hist_most}$b"