Skip to content

There are many a code2prompt tools about, but this one is mine 🪖 (fzf powered, local/remote, now with grepping!)

License

Notifications You must be signed in to change notification settings

LemuelCushing/cafeznik

Repository files navigation

Cafeznik

Not a fez-wearing cat in a track suit.

There are many code2prompt tools around, but this one is mine 🪖

What is this?

Cafeznik is an interactive CLI (levereging the beautiful fzf) to ease the selection and copying of code files - local or remote (GitHub) - to your clipboard.

Why? You know why - so I can feed it into LLMs like the lazy, lazy script kiddie vibe programmer I am. It’s streamlined, efficient, and dangerously habit-forming.

Installation

Install it directly via RubyGems (requires Ruby 3.3 and the other dependencies listed below):

gem install cafeznik

Then what?

cafeznik # or cafeznik --repo owner/repo

use tab to select multiple files, enter to copy them to your clipboard, and ctrl-c/esc to exit. Selecting a directory will copy all files within it, and selecting ./ will copy everything in sight (respecting your --excludes and --greps ).

looksee

Local mode: asciicast Or remote with grep and exclude: asciicast

Dependencies

Cafeznik relies on a few external tools to work its magic:

  • fzf – Essential for interactive file selection (absolutely required)
  • fd – Powers local file discovery (required for local mode)
  • ripgrep – Enables efficient grep functionality (required when using --grep)
  • bat (& tree) – Provide pretty previews (optional but highly recommended)
  • gh – Simplifies GitHub authentication (optional; you can alternatively set the GITHUB_TOKEN environment variable)

A homebrew line to install all the dependencies on macOS:

brew install fzf fd ripgrep bat tree gh

Usage

Local mode

Quickly select and copy files from your current directory:

cafeznik

Filter your selection to include only files that contain specific text:

cafeznik --grep "def initialize"

Easily exclude unwanted files or directories:

cafeznik --exclude "*.log" --exclude "tmp/"

GitHub mode

Fetch and copy code directly from any GitHub repository:

cafeznik --repo owner/repo

It also supports full URLs:

cafeznik --repo https://github.com/owner/repo

Noteworthy Flags

--repo, -r        Specify a GitHub repository to fetch files from 
--grep, -g        Only select files containing specific text patterns (works locally and remotely)
--exclude, -e     Exclude files or directories matching provided patterns (also works locally and remotely)
--with-tree, -t   Include a detailed file tree structure in your output (Guess what? Works locally and remotely)

Less important flags

--no-header       Omit file headers from the copied content for a cleaner paste
--verbose         Activate detailed logging output for debugging and transparency

Or, you know:

cafeznik --help

What's a-comin

  • History of copied files - so you can easily re-copy them. Rinse, repeat.
  • Optional minification of copied files
  • Binary files support for multi-modal models? Might be a stretch
  • Token counting. Everyone loves token counting.

Noteworthy Competitors I did not take inspiration from

  • gitingest - Fellow Ruby that works much better on bigger repos, and packs it all nicely in a prompt file
  • onefilellm - Does so much more, expect it's a completely different thing
  • your-source-to-prompt.html - If you wanna leave your console for a browser, you'll get plenty of nice features for your code2prompt needs

License

Cafeznik is open-source software, licensed under the MIT License.

Contributing

Please! Feel free, this over-engineered tool welcomes all interested parties and fiestas.

Enjoy your freshly copied code! 🍪

About

There are many a code2prompt tools about, but this one is mine 🪖 (fzf powered, local/remote, now with grepping!)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published