Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

License

NotificationsYou must be signed in to change notification settings

bellecp/fast-p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quickly find and open a pdf among a collection of thousands of unsorted pdfs through fzf (fuzzy finder)

Installation on Unix or Linux based systems

  1. Requirements. Make sure the following requirements are satisfied:

    • installpdftotext. This comes with the texlive distribution on linux,On ubuntu,sudo apt-get install poppler-utils .
    • installfzf:https://github.com/junegunn/fzf
    • installGNU grep,ag (silver searcher).
  2. Install binary. Do either one of the two steps below:

    • Compile from source withgo andgo get.With a workinggolang installation, dogo install github.com/bellecp/fast-p@v0.2.5It will fetch the code and its dependencies,compile and create an executablefast-p in the/bin folder of your goinstallation, typically~/go/bin. Make sure the commandfast-p can befound (for instance, add~/go/bin to your$PATH.)
    • Or:Use the precompiled binary for your architecture. Download the binary that corresponds to yourarchitecture athttps://github.com/bellecp/fast-p/releases and make sure thatthe commandfast-p can be found. For instance,put the binary filefast-p in~/custom/bin and addexport PATH=~/custom/bin:$PATH to your.bashrc.
  3. Tweak your .bashrc. Add the following code to your.bashrc

p () {    open=xdg-open   # this will open pdf file withthe default PDF viewer on KDE, xfce, LXDE and perhaps on other desktops.    ag -U -g ".pdf$" \    | fast-p \    | fzf --read0 --reverse -e -d $'\t'  \        --preview-window down:80% --preview '            v=$(echo {q} | tr " " "|");             echo -e {1}"\n"{2} | grep -E "^|$v" -i --color=always;        ' \    | cut -z -f 1 -d $'\t' | tr -d '\n' | xargs -r --null $open > /dev/null 2> /dev/null}
  • You may replaceag -U -g ".pdf$" with another command that returns a list of pdf files.
  • You may replaceopen=... by your favorite PDF viewer, for instanceopen=evince oropen=okular.

Installation on OSX with homebrew

  1. Installhomebrew andrun
brew install bellecp/fast-p/fast-pdf-finder

The above brew formula is experimental.Please report any issues/suggestions/feedback at#11

  1. Tweak your .bashrc. Add the following code to your.bashrc
p () {    local open    open=open   # on OSX, "open" opens a pdf in preview    ag -U -g ".pdf$" \    | fast-p \    | fzf --read0 --reverse -e -d $'\t'  \        --preview-window down:80% --preview '            v=$(echo {q} | gtr " " "|");             echo -e {1}"\n"{2} | ggrep -E "^|$v" -i --color=always;        ' \    | gcut -z -f 1 -d $'\t' | gtr -d '\n' | gxargs -r --null $open > /dev/null 2> /dev/null}
  • You may replaceag -U -g ".pdf$" with another command that returns a list of pdf files.
  • You may replaceopen=... by your favorite PDF viewer, for instanceopen=evince oropen=okular.

Remark: On OSX, we use the command line toolsgcut,gxargs,ggrep,gtr which are the GNU versionsof the toolscut,xargs,grep,tr. This way, we avoid the specifics of the versions of these tools pre-installed on OSX,and the same.bashrc code can be used for both OSX and GNU Linux systems.

Usage

Use the commandp to browse among the PDF files in the current directory and its subdirectories.

The first run of the command will take some time to cache the text extracted from each pdf. Further runs of the command will be much faster since the text extraction will only apply to new pdfs.

How to clear the cache?

To clear the cache (which contains text extracted from PDF), you can run 'fast-p --clear-cache'. This will safely remove the file located at:~/.cache/fast-p-pdftotext-output/fast-p_cached_pdftotext_output.db

For older versions, please manually delete the cache file found at~/.cache/fast-p_cached_pdftotext_output.db

Launch with keyboard shortcut in Ubuntu

On Ubuntu desktop (tested in 18.04), one may add a keyboard shortcut to launch a new terminal running thep command right away.With the following script, the new terminal window will automatically close after choosing a PDF.

Create a file~/.fast-p-rc with

source .bashrcp;sleep 0.15; exit;

and in Ubuntu Settings/Keyboard, add a custom shortcut that runs the commandgnome-terminal -- sh -c "bash --rcfile .fast-p-rc".

See it in action

illustration of the p command

Is the historical bash code still available?

Yes, seehttps://github.com/bellecp/fast-p/blob/master/p but using the go binary as explained above is recommended for speed and interoperability.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp