From 0c7f1d7e8de277ede9db9f861049360b80580163 Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Sun, 24 Mar 2019 09:26:15 +0100 Subject: [PATCH] Add an option to increase verbosity (e.g. to mark installed packages) --- saury | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/saury b/saury index 085e747..30bfbef 100755 --- a/saury +++ b/saury @@ -51,7 +51,8 @@ function print_usage print_operation "{-V --version}" print_operation "{-A --aur-sync} [options] [package(s)]" echo 'options:' - echo ' --color ' + echo ' -c, --color=' + echo ' -v, --verbose' end function print_version @@ -82,6 +83,13 @@ function aur_search map(.Name, .PackageBase, .Description, .Version, .OutOfDate != null, .NumVotes, (.Popularity * 100 | round / 100))[]') + if test $_flag_verbose + begin + set -l IFS + set installed_packages (pacman -Q) + end + end + for i in (seq (math (count $results) / 7)) set name $results[(math $i \* 7 - 6)] set package_base $results[(math $i \* 7 - 5)] @@ -117,6 +125,22 @@ function aur_search (set_color CC6733) "$popularity" \ (set_color normal; set_color --bold) ')') + if test $_flag_verbose + # not shown by default because it's quite slow + + set installed (echo $installed_packages | grep -E "^$name ") + if test "$installed" + echo -n ' [installed' + set installed_version (echo $installed | cut -d' ' -f2) + + if test "$package_version" != "$installed_version" + echo -n ": $installed_version" + end + + echo -n ']' + end + end + echo set_color normal @@ -165,7 +189,7 @@ function main set aur_sync_exclusive_options 's,u' argparse -n $saury_name -x 'V,A' -x $aur_sync_exclusive_options \ - 'h/help' 'V/version' 'A/aur-sync' 'c-color=?' $aur_sync_options -- $argv \ + 'h/help' 'V/version' 'A/aur-sync' 'c/color=?' 'v/verbose' $aur_sync_options -- $argv \ ^| sed (string join '' 's/:/:' (set_color red) '/;s/$/' (set_color normal) '/') | head -1 if not set --local --query argv @@ -182,6 +206,10 @@ function main end end + if test $_flag_verbose + set -g _flag_verbose $_flag_verbose + end + if set --query _flag_help print_usage else if set --query _flag_version