work in progress
This commit is contained in:
parent
f3a41e035d
commit
5322dd0382
2
PKGBUILD
2
PKGBUILD
|
@ -1,6 +1,6 @@
|
||||||
# Maintainer: Eric Lay <ericlaytm@gmail.com>
|
# Maintainer: Eric Lay <ericlaytm@gmail.com>
|
||||||
pkgname=fuzzy-pkg-finder
|
pkgname=fuzzy-pkg-finder
|
||||||
pkgver=0.8.3
|
pkgver=0.8.4
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Simple cli command for using fzf to search and install packages"
|
pkgdesc="Simple cli command for using fzf to search and install packages"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
|
|
@ -21,9 +21,9 @@ Defaults to Pacman if no options passed
|
||||||
|
|
||||||
options:
|
options:
|
||||||
a Search/List and install from AUR with Yay
|
a Search/List and install from AUR with Yay
|
||||||
l Search/List installed packages from official repo
|
l Search/List installed packages from official repo
|
||||||
la Search/List installed packages from AUR repo
|
la Search/List installed packages from AUR repo
|
||||||
R Search/List installed packages from official repos for removal
|
R Search/List installed packages from official repos for removal
|
||||||
Ra Search/List installed packages from AUR repo for removal
|
Ra Search/List installed packages from AUR repo for removal
|
||||||
h Print this help screen.
|
h Print this help screen.
|
||||||
```
|
```
|
||||||
|
|
48
fpf
48
fpf
|
@ -25,38 +25,36 @@ Help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
### Manjaro Repo
|
### 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
|
#Double check things are up to date
|
||||||
UpdateInfos() {
|
UpdateInfos() {
|
||||||
[ -f /tmp/core/core.files.tar.gz ] || GetDB
|
[ -f /var/lib/pacman/sync/core.files ] || { echo -e "Syncing files database"; sudo pacman -Fy }
|
||||||
d1=$(stat -c %y /tmp/core/core.files.tar.gz)
|
d1=$(stat -c %y /var/lib/pacman/sync/core.files)
|
||||||
d2=$(stat -c %y /var/lib/pacman/sync/core.db)
|
d2=$(stat -c %y /var/lib/pacman/sync/core.db)
|
||||||
d1="${d1:0:10}"
|
d1="${d1:0:10}"
|
||||||
d2="${d2: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
|
#Get Manjaro package list, sort, mark installed, preview infos and finally hand off to pacman for install
|
||||||
Mrepo() {
|
Mrepo() {
|
||||||
echo "Setting things up..."
|
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
|
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
|
||||||
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
|
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
|
# List installed pkgs
|
||||||
Installed() {
|
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 installed pkgs
|
||||||
Remove() {
|
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
|
### 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
|
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
|
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
|
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
|
# List installed pkgs from AUR
|
||||||
AurInstalled() {
|
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 installed pkgs from AUR
|
||||||
Remove() {
|
AurRemove() {
|
||||||
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
|
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
|
### ORPHANS
|
||||||
|
@ -85,9 +88,10 @@ Remove() {
|
||||||
|
|
||||||
### MAIN
|
### MAIN
|
||||||
|
|
||||||
|
# First we update the files database
|
||||||
|
UpdateInfos
|
||||||
# Test for AUR option, if not run with pacman
|
# Test for AUR option, if not run with pacman
|
||||||
if [[ ! "$1" =~ "-" ]]; then
|
if [[ ! "$1" =~ "-" ]]; then
|
||||||
UpdateInfos
|
|
||||||
Mrepo "$1"
|
Mrepo "$1"
|
||||||
else
|
else
|
||||||
for opt in "$@"; do
|
for opt in "$@"; do
|
||||||
|
@ -102,9 +106,9 @@ else
|
||||||
-la|--list-aur-installed)
|
-la|--list-aur-installed)
|
||||||
AurInstalled "$2"
|
AurInstalled "$2"
|
||||||
;;
|
;;
|
||||||
-o|--orphans)
|
# -o|--orphans)
|
||||||
Orphans "$2"
|
# Orphans "$2"
|
||||||
;;
|
# ;;
|
||||||
-R|--remove)
|
-R|--remove)
|
||||||
Remove "$2"
|
Remove "$2"
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue