From 82c1fdb5814eb0f393fd79012745929fa7fed3f0 Mon Sep 17 00:00:00 2001 From: Seppia Date: Sat, 2 Jun 2018 19:08:31 +0200 Subject: Color support and initial installed package info Added support for colored output in search mode and mark packages already present locally. --- repo.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/repo.sh b/repo.sh index 36243a9..651aa8e 100755 --- a/repo.sh +++ b/repo.sh @@ -108,10 +108,13 @@ search_packages() { declare -a key=("${!1}") CURL_JSN=$(curl -s $(echo ${URL_PREFIX}${SEARCH_STR}"${key[@]}" | sed -e 's/ /+/g')) OUT_STR=$(jq -r '.results | .[] | [.Name, .Version], .Description' <<< ${CURL_JSN}) + SEARCH_OUT=$(sed -e 's/\\//g' -e 's/\[/\\033\[1\;36m\[/g' -e 's/",/\\033\[1\;33m", \[\\033\[1\;32m/g' \ + -e 's/\]/\\033\[1\;33m\]\\033\[1\;37m\]/g' <<< ${OUT_STR}) printf 'You searched using the following keywords (matching package name and/or description): "' printf '%s ' "${key[@]}" printf '\b"\n' - echo ${OUT_STR} | sed -e 's/\[ /\n/g' -e 's/ *\] /\n\t/g' -e 's/"*, /\//g' -e 's/"//g' + echo -e ${SEARCH_OUT} | sed -e 's/\[ /\n/g' -e 's/ *\] /\n\t/g' -e 's/", / /g' -e 's/"//g' | for i in $($0 list); do + sed '/'"$i"'[^-]/ s/$/ '"$(echo -e \\033\[1\;35m[ Installed ]\\033\[1\;37m)"'/'; done } set_variables() { -- cgit v1.2.3