work in progress

This commit is contained in:
Eric Lay 2020-06-27 15:59:20 -05:00
parent f3a41e035d
commit 5322dd0382
3 changed files with 31 additions and 27 deletions

View File

@ -1,6 +1,6 @@
# Maintainer: Eric Lay <ericlaytm@gmail.com>
pkgname=fuzzy-pkg-finder
pkgver=0.8.3
pkgver=0.8.4
pkgrel=1
pkgdesc="Simple cli command for using fzf to search and install packages"
arch=('any')

View File

@ -21,9 +21,9 @@ Defaults to Pacman if no options passed
options:
a Search/List and install from AUR with Yay
l Search/List installed packages from official repo
la Search/List installed packages from AUR repo
R Search/List installed packages from official repos for removal
Ra Search/List installed packages from AUR repo for removal
l Search/List installed packages from official repo
la Search/List installed packages from AUR repo
R Search/List installed packages from official repos for removal
Ra Search/List installed packages from AUR repo for removal
h Print this help screen.
```

48
fpf
View File

@ -25,38 +25,36 @@ Help() {
}
### Manjaro Repo
#Get pkg infos and files lists, bypassing 'sudo pacman -Fy' because entering a password to view pkg info is silly
GetDB() {
wget -P /tmp/core/ https://mirror.datacenter.by/pub/mirrors/manjaro/stable/core/"$type"/core.files.tar.gz >/dev/null 2>&1 && tar xzf /tmp/core/core.files.tar.gz -C /tmp/core 2> /dev/null
}
#Double check things are up to date
UpdateInfos() {
[ -f /tmp/core/core.files.tar.gz ] || GetDB
d1=$(stat -c %y /tmp/core/core.files.tar.gz)
[ -f /var/lib/pacman/sync/core.files ] || { echo -e "Syncing files database"; sudo pacman -Fy }
d1=$(stat -c %y /var/lib/pacman/sync/core.files)
d2=$(stat -c %y /var/lib/pacman/sync/core.db)
d1="${d1:0:10}"
d2="${d2:0:10}"
[[ "${d2///-/}" > "${d1//-/}" ]] && GetDB
[[ "${d2///-/}" > "${d1//-/}" ]] && { echo -e "Files database is out of date\nSyncing now..."; sudo pacman -Fy }
}
#Get Manjaro package list, sort, mark installed, preview infos and finally hand off to pacman for install
Mrepo() {
echo "Setting things up..."
sort <(comm -23 <(pacman -Sl | sort) <(pacman -Q | sort)) <(comm -12 <(pacman -Sl | sort) <(pacman -Q | sort) | awk '{$1=""; print $0" \033[32m*\033[0m"}') > /tmp/packages
cat /tmp/packages |fzf -q "$1" -e -m --preview 'cat <(cat /tmp/core/{1}/desc) <(cat /tmp/core/{1}/files)' --preview-window=wrap --layout=reverse --marker='>>' --header="Select packages to install (use TAB to toggle selection)" --info=hidden --ansi | xargs -ro sudo pacman -S
sort <(comm -23 <(pacman -Slq | sort) <(pacman -Qq | sort)) <(comm -12 <(pacman -Slq | sort) <(pacman -Qq | sort) | awk '{print $0" \033[32m*\033[0m"}') > /tmp/packages
echo "$(echo -e ' Select packages to install\n (use TAB to toggle selection)'; cat /tmp/packages)" > /tmp/packages
cat /tmp/packages |fzf -q "$1" -e -m --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} | awk "{print \$2}")' --preview-window=65%:wrap --layout=reverse --marker='>>' --header-lines=2 --info=hidden --ansi --margin="2%,1%,2%,1%" --cycle | xargs -ro sudo pacman -S
}
# List installed pkgs
Installed() {
sort <(pacman -Qqs) |fzf -q "$1" -e -m --preview 'cat <(pacman -Qi {1}) <(pacman -Fl {1} | awk "{print \$2}")' --preview-window=wrap --layout=reverse --marker='>>' --header="Select packages to install (use TAB to toggle selection)" --info=hidden --ansi | xargs -ro pacman -Qik
sort <(pacman -Qqs) > /tmp/installed_packages
echo "$(echo -e ' Select packages to print info\n (use TAB to toggle selection)'; cat /tmp/installed_packages)" > /tmp/installed_packages
cat /tmp/installed_packages |fzf -q "$1" -e -m --preview 'cat <(pacman -Qik {1}) <(echo "") <(pacman -Fl {1} | awk "{print \$2}")' --preview-window=65%:wrap --layout=reverse --marker='>>' --header-lines=2 --info=hidden --ansi --margin="2%,1%,2%,1%" --cycle | xargs -ro pacman -Qik
}
# Remove installed pkgs
Remove() {
sort <(pacman -Qqs) |fzf -q "$1" -e -m --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} | awk "{print \$2}")' --preview-window=wrap --layout=reverse --marker='>>' --header="Select packages to install (use TAB to toggle selection)" --info=hidden --ansi | xargs -ro sudo pacman -Rsn
sort <(pacman -Qqs) > /tmp/installed_packages
echo "$(echo -e ' Select packages to remove\n (use TAB to toggle selection)'; cat /tmp/installed_packages)" > /tmp/installed_packages
cat /tmp/installed_packages |fzf -q "$1" -e -m --preview 'cat <(pacman -Si {1}) <(pacman -Fl {1} | awk "{print \$2}")' --preview-window=65%:wrap --layout=reverse --marker='>>' --header-lines=2 --info=hidden --ansi --margin="2%,1%,2%,1%" --cycle | xargs -ro sudo pacman -Rsn
}
### AUR Repo
@ -65,17 +63,22 @@ Arepo() {
wget -P /tmp/aur/ https://aur.archlinux.org/packages.gz >/dev/null 2>&1 && gunzip -f /tmp/aur/packages.gz
echo "$(tail -n +2 /tmp/aur/packages)" > /tmp/aur/packages
sort <(comm -23 <(sort /tmp/aur/packages) <(pacman -Qq | sort)) <(comm -12 <(sort /tmp/aur/packages) <(pacman -Qq | sort) | awk '{print $0" \033[32m*\033[0m"}') > /tmp/aur_packages
cat /tmp/aur_packages | fzf -q "$1" -e -m --preview 'cat <(yay -Si {1}) <(pacman -Ql {1} 2>/dev/null | awk "{print \$2}")' --preview-window=wrap --layout=reverse --marker='>>' --header="Select packages to install (use TAB to toggle selection)" --info=hidden --ansi | xargs -ro yay -S
echo "$(echo -e ' Select packages to install\n (use TAB to toggle selection)'; cat /tmp/aur_packages)" > /tmp/aur_packages
cat /tmp/aur_packages | fzf -q "$1" -e -m --preview 'cat <(yay -Si {1}) <(pacman -Ql {1} 2>/dev/null | awk "{print \$2}")' --preview-window=65%:wrap --layout=reverse --marker='>>' --header-lines=2 --info=hidden --ansi --margin="2%,1%,2%,1%" --cycle | xargs -ro yay -S
}
# List installed pkgs from AUR
AurInstalled() {
sort <(pacman -Qqm) |fzf -q "$1" -e -m --preview 'cat <(yay -Qi {1}) <(pacman -Ql {1} | awk "{print \$2}")' --preview-window=wrap --layout=reverse --marker='>>' --header="Select packages to install (use TAB to toggle selection)" --info=hidden --ansi | xargs -ro pacman -Qik
sort <(pacman -Qqm) > /tmp/aur_installed_packages
echo "$(echo -e ' Select packages to print info\n (use TAB to toggle selection)'; cat /tmp/aur_isntalled_packages)" > /tmp/aur_installed_packages
cat /tmp/aur_installed_packages |fzf -q "$1" -e -m --preview 'cat <(yay -Qi {1}) <(echo "") <(pacman -Ql {1} | awk "{print \$2}")' --preview-window=65%:wrap --layout=reverse --marker='>>' --header-lines=2 --info=hidden --ansi --margin="2%,1%,2%,1%" --cycle | xargs -ro pacman -Qik
}
# Remove installed pkgs from AUR
Remove() {
sort <(pacman -Qqm) |fzf -q "$1" -e -m --preview 'cat <(yay -Qi {1}) <(pacman -Ql {1} | awk "{print \$2}")' --preview-window=wrap --layout=reverse --marker='>>' --header="Select packages to install (use TAB to toggle selection)" --info=hidden --ansi | xargs -ro sudo pacman -Rsn
AurRemove() {
sort <(pacman -Qqs) > /tmp/aur_installed_packages
echo "$(echo -e ' Select packages to print remove\n (use TAB to toggle selection)'; cat /tmp/installed_packages)" > /tmp/aur_installed_packages
cat /tmp/aur_installed_packages |fzf -q "$1" -e -m --preview 'cat <(yay -Qi {1}) <(pacman -Ql {1} | awk "{print \$2}")' --preview-window=65%:wrap --layout=reverse --marker='>>' --header-lines=2 --info=hidden --ansi --margin="2%,1%,2%,1%" --cycle | xargs -ro sudo pacman -Rsn
}
### ORPHANS
@ -85,9 +88,10 @@ Remove() {
### MAIN
# First we update the files database
UpdateInfos
# Test for AUR option, if not run with pacman
if [[ ! "$1" =~ "-" ]]; then
UpdateInfos
Mrepo "$1"
else
for opt in "$@"; do
@ -102,9 +106,9 @@ else
-la|--list-aur-installed)
AurInstalled "$2"
;;
-o|--orphans)
Orphans "$2"
;;
# -o|--orphans)
# Orphans "$2"
# ;;
-R|--remove)
Remove "$2"
;;