Skip to content

Use fzf to browse and preview all files installed by a pacman-managed package.

License

Notifications You must be signed in to change notification settings

kielmarj/fzf-pkg-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fzf-pkg-files

Jump to Section
  1. Features
  2. Installation
    2.1 Dependencies
  3. Usage
    3.1 Extending File Previews
  4. Contributing
  5. License

fzf-pkg-files-screenshot.png

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.

Features

fzf-pkg-files.gif gif made with asciinema and agg

★ Interactive File Browsing ★
Use fzf to interactively browse through all files installed by a specific package.
★ Preview Many File Types ★
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.
★ Syntax Highlighting ★
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.

Installation

  1. Clone the Repository:
    git clone https://github.com/kielmarj/fzf-pkg-files.git
  2. CD into the cloned-directory and make the script executable:
    cd fzf-pkg-files/script
    chmod +x fzf-pkg-files
  3. Optionally, move the script to a directory in your PATH

Dependencies

Required
Ensure the following dependencies are installed on your system:

  • fzf - A command-line fuzzy finder.
  • pacman - The package manager for Arch Linux.
  • bat - A cat(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 by fzf-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 the gzip package. Used by fzf-pkg-files to render previews of Info files.
  • pdftotext - Simple PDF text extraction.

Usage

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.

Extending File Previews

To support additional file types or tweak an existing preview, edit the get_preview_command function in fzf-pkg-files:

  1. Add a new elif condition based on the file extension, MIME type, or encoding.
  2. Use bat or another tool for previewing.

Example for .log files:

elif [[ "$file" =~ \.log$ ]]; then
    bat --language=log "$file"

Contributing

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 😉.

License

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.



© 2024 kielmarj | Licensed under the MIT License
Buy Me A Coffee

About

Use fzf to browse and preview all files installed by a pacman-managed package.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages