Skip to content

Instantly share code, notes, and snippets.

@Koitharu
Created October 25, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Koitharu/14c87b975782575efc1f4a93b2618191 to your computer and use it in GitHub Desktop.
Save Koitharu/14c87b975782575efc1f4a93b2618191 to your computer and use it in GitHub Desktop.
#!/bin/bash
res=`dnf search "$1" 2>&1`
if [ $? -eq 0 ]; then
i=0
while read -r line; do
if [[ "$line" =~ " : " ]]; then
((i++))
IFS=':' read -r -a pkg <<< "$line"
pkgi="${pkg[0]}"
pkgi=${pkgi//[[:blank:]]/}
pkgs[i]="$pkgi"
printf "\033[1m%s\033[0m \x1b[93m%s\x1b[0m %s\n" "$i" "$pkgi" "${pkg[1]}"
fi
done <<< "$res"
printf "Install > "
read -r pknum
dnf install "${pkgs[pknum]}"
else
printf "\x1b[31m\033[1m%s\x1b[0m\n" "$res";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment