From d0210580b12d50cf925352b652bece168c4336b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Thu, 14 Mar 2024 16:24:48 +0100 Subject: [PATCH] Refactor zrep_list_installed_packages function - Added zmodload zsh/regex for regex support - Changed grep to regex match for package activation check - Updated zrep_msg output format --- zrep | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zrep b/zrep index 53e4aac..d14ca39 100755 --- a/zrep +++ b/zrep @@ -293,12 +293,13 @@ function zrep_list_installed_packages() { local package_name=$(echo "${package_info}" | cut -d ' ' -f1) # Extract package name before the version local is_active="${base_colors[white]}(${base_colors[end]}${base_colors[bold_red]}Inactive${base_colors[end]}${base_colors[white]})${base_colors[end]}" # Set default to Inactive + zmodload zsh/regex # Check if the package is active (only modify if active) - if grep -q "${package_name}" ${config[main_zrep_install_dir]}/.addons; then + if [[ $(<${config[main_zrep_install_dir]}/.addons) =~ "\b${package_name}\b" ]]; then is_active="${base_colors[white]}(${base_colors[end]}${base_colors[bold_green]}Active${base_colors[end]}${base_colors[white]})${base_colors[end]}" fi - zrep_msg info " - ${package_info} ${is_active}" + zrep_msg info " |> ${package_info} ${is_active}" done }