fzf pkg search and install

I've created a simple tool to leverage fzf for searching, viewing infos and installing packages. Works with Manjaro/Arch repos (pacman) and AUR (yay).

This is a learning process so please test, break and report back if interested.


git clone https://github.com/ericlay/fuzzy-pkg-finder
cd fuzzy-pkg-finder
makepkg -sric


Syntax: fpf -[a|l|la|R|o|h]
Defaults to Pacman if no options passed

a     Search/List and install from AUR with Yay
l     Search/List installed packages from official repo
la    Search/List installed packages from AUR 
R     Search/List installed packages from official repos for removal
o     Search/List orphaned packages for removal
h     Print this help screen.

Shout-outs for guidance along the way @dalto @chrysostomus @papajoke @xircon

  • why not pass search in parameter as fpf [-y] searchword
...() {    # in 2 functions
    ... |fzf -q "$1" -e -m --preview  ...
if [[ ! "$1" =~ "-" ]]; then
	Mrepo $1
    Arepo $2

  • params
    I prefer
    • -r [search] : in repos
    • -a [search] : in aur

why not (as mhwd)

  • add -li : list only installed (and add also only explicites ?)
  • add -l[r|a] : list all - as -r -a but not run install at end
  • and orphans ?

problem for list file with aur, we show errors (-Fl is only for repos)
we can list file only if installed :wink:
and pacman -Fl XX | awk "{print $2}" == pacman -Flq XX

Arepo() {
--preview  'cat <(yay -Si {1}) <(yay -Fl {1} | awk "{print \$2}")'


cat <(yay -Si {1}) <(pacman -Qq {1} &>/dev/null && pacman -Qlq |grep -v "\/$"  {1})

you can add color for * "installed" (pass --ansi to fzf)

awk '{print $0" \033[32m*\033[0m"}'

Excellent ideas! I'm a little out of time today but will parse and work on these.

Especially considering I planned to add remove functionality as well.

fpf emacs

As an example, does not default to pacman...... Just woke up (first :coffee:).

Does it not take a starting clp for the package? (Yaaaawwwwn). :rofl:

Reading the script - the above should be "invalid usage" but it doesn't trigger. Remove the "-" from "-*".

Doesn't pick up third party repos:

So needs a pacman -Fy first???

add top code ?

  [ -f /var/lib/pacman/sync/core.files ] || sudo pacman -Fy

and after compare dates (need update)

d1=$(stat -c %y /var/lib/pacman/sync/core.files)
d2=$(stat -c %y /var/lib/pacman/sync/core.db)
[[ "${d2//-/}" > "${d1//-/}" ]] && sudo pacman -Fy

It's written in a way avoid doing pacman -Fy It would require sudo permission s every time.

Edit: it also is becoming much more than a search utility so maybe permissions isn't a biggy, I just am not a fan of using your pw for a simple search

I may not include 3rd party repos, I'm not a big fan of them :thinking:

Almost outta work, going to crack into this guy in a bit. I'm weighing out which way to go with this. I could go back to using paxman -Fy and use 3rd party repos too, how do y'all feel about a syatemd timer that syncs the file db once a day? Too clunky? @xircon @papajoke

See "v0.5" for hiw I was using a timer

i have written a similar tool called pacui:

feel free to use it for any inspiration you want...

you can only look at pacui's help page (either directly in code here or by calling "pacui help" from your terminal) or look at the code directly.
i also use fzf (as seen in the code here for selecting and installing packages).

doing your own script helps you to learn pacman/yay and get to know bash scripting. have fun!


I took the time I had today to review @papajoke's suggestions and pacui and have added some new features. They are very green and I've already noticed some errors. (Re-installing a package fails because it also tries to install the '*' annotation)

Also realized what you meant by:

I totally misunderstood some things. Using ...pacman -Ql 2>/dev/null... pulls files listing for installed and dumps the error if not.

New state is up at above link.

Looking further into @xircon's suggestions and @papajoke's second comment I've realized how to pull the repo.files.db manually. This will get the files list without needing permissions for a simple search. I should also be able to add a way to tie in more popular third party repo's or to manually point to one (heavy maybe on the latter).

I understand the slicing but what does this do? @papajoke

If I'm not mistaken this should remove all occurences of - in the string held in variable d2.


for compare after 2 date as integers
2020-06-27 => 20200627
if ( 20206227 > 20200625 )


1 Like

Small update

I've ditched the effort to not use pacman -Fy, it's possible but seems like much to do about nothing. As I'm learning more about pacman/yay/alpm, I see the tools are already available to do such. It would require either the final listing to have version numbers (ugly) or I could change all the dir names in the files.db to match the lines from pacman -Slq (needlessly complex).

With that I've implemented your suggestions @papajoke, they work excellent. Thank you.

@xircon maybe try again and see if it will work with 3rd party repos?

v0.9.1 is up now, It feels a lot more complete but, surely has room for improvement. It can now list and remove orphans. Uses a single function to remove packages. Correctly strips '*' from installed packages for re-installation.

1 Like

Forum kindly sponsored by