Skip to content

Commit

Permalink
perf: use string manipulation to extract exact error message in Clean…
Browse files Browse the repository at this point in the history
…-Log feature

Use string manipulation to extract the main message from builtin cd error in Clean-Log feature.
  • Loading branch information
CodesOfRishi committed Jan 17, 2022
1 parent 12dd48a commit a66aaf2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions feats/hist-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a66aaf2

Please sign in to comment.