#!/bin/sh

if [ -z "$1" ]
then
  echo "Usage:
  -i : install a package
  -u : uninstall a package"
else
  if [ "$1" = "-i" ]
  then
    yay -Slq | fzf --multi --preview 'yay -Si {1}' | xargs -ro yay -S
  elif [ "$1" = "-u" ]
  then
    yay -Qq | fzf --multi --preview 'cat <(yay -Si {1}) <(yay -Fl {1} | awk "{print \$2}")' | xargs -ro yay -Rns
  else
    exit 1
  fi
fi
