gists/pdf_finder_raku_script.html

PDF Finder Raku Script

This helper script finds PDF-files recursively and lets the user fuzzy select the one to open.

A directory can be given as argument otherwise $HOME will be used.

Dependencies in the script comment below.

I also use a similar script as a keybinding in Niri where the files are selected using fuzzel instead.

#!/usr/bin/env raku

# PDF file finder and opener
#
# Depends on:
#   fd
#   fzf
#   zathura
#

sub MAIN($dir = %*ENV<HOME>) {

  chdir $dir;

  my $pdf = shell("fd -e pdf | fzf", :merge).out.lines()[0];

  shell("zathura \"$dir/$pdf\" 2> /dev/null") if $pdf;
}