Jump to Section
fzf-pkg-files
is a user-friendly Bash script that leverages fzf
to browse and preview all files installed by a pacman-managed package. This tool is particularly useful for Arch Linux users who want to quickly locate and inspect files associated with a specific package.
fzf-pkg-files
is straightforward and easy to use. It only requires a single argument: either the name of an installed package, or the name of an installed command.
gif
made with asciinema
and agg
Use fzf to interactively browse through all files installed by a specific package. |
Preview the contents of various file types, including pretty manpages , info files , PDFs ,images , and more directly within the fzf preview-window. |
HTML previews are stripped of distracting HTML tags and neatly formatted by html-to-markdown , allowing you to focus on the actual content without the visual clutter of raw HTML. |
Each file type has been carefully formatted for optimal readability. Enjoy syntax-highlighting for many languages, including css , shellscripts , JavaScript , json , Markdown , Python , TypeScript , yaml , and many more. |
Note: this script does not actually alter any files. Formatting and syntax-highlighting only occur as a live-preview within fzf
.
- Clone the Repository:
git clone https://github.com/kielmarj/fzf-pkg-files.git
- CD into the cloned-directory and make the script executable:
cd fzf-pkg-files/script chmod +x fzf-pkg-files
- Optionally, move the script to a directory in your PATH
Required
Ensure the following dependencies are installed on your system:
fzf
- A command-line fuzzy finder.pacman
- The package manager for Arch Linux.bat
- Acat(1)
clone with wings.
Optional
The following tools are optional but recommended for optimal file previews:
kitty
- Cross-platform, fast, feature-rich, GPU-based terminal. Used byfzf-pkg-files
to generate image previews.html-to-markdown
- Convert HTML to Markdown. Even works with entire websites and can be extended through rules.zcat
- Provided by thegzip
package. Used byfzf-pkg-files
to render previews ofInfo files
.pdftotext
- Simple PDF text extraction.
To use fzf-pkg-files
, simply run the script followed by the name of an installed package or command:
fzf-pkg-files <NAME OF INSTALLED PACMAN-MANAGED PACKAGE -OR- COMMAND>
In fzf
, use TAB to select multiple files, ENTER to open selected files in a pager, & ESC to exit fzf
& print selected file paths to stdout
.
To support additional file types or tweak an existing preview, edit the get_preview_command
function in fzf-pkg-files
:
- Add a new
elif
condition based on the file extension, MIME type, or encoding. - Use
bat
or another tool for previewing.
Example for .log
files:
elif [[ "$file" =~ \.log$ ]]; then
bat --language=log "$file"
Contributions are welcome! If you have suggestions for improvements or encounter any issues, feel free to reach out, open an issue, submit a pull request. If you're really motivated, check out the todo list 😉.
This project is licensed under the MIT License, so feel free to modify, reuse, share, etc as long as you include the original copyright and notice included in the LICENSE file.