#!/bin/sh

prog=${0##*/}

case "$1" in
	-a) apk list -a | awk -F' ' '{print $1}' | sed 's/-[^-]*-r[0-9]*//g' | sort -u | fzf --prompt "Packages: " --preview 'apk info -a {}' ;;
	-i) apk list -I | awk -F' ' '{print $1}' | sed 's/-[^-]*-r[0-9]*//g' | sort -u | fzf --prompt "Packages: " --preview 'apk info -a {}' ;;
	-m) fzf --prompt "Packages: " --preview 'apk info -a {}' < /etc/apk/world ;;
	*) echo "Usage: $prog -a: list all packages
	$prog -i: list all installed packages
	$prog -m: list manually installed packages" ;;
esac
