A small cache for unique lines of text, used to speedup the load time of expensive fzf invocations
Given any shell command as positional arguments:
- If that command has been run in the past (determined by hashing the command itself), immediately prints the cached value -- this means you can immediately select something with
fzf
- Prints any lines from that shell command to STDOUT, which haven't already been printed from the cachefile, removing any duplicates
- Once the shell command exits, saves the output of the shell command to a file in
~/.cache/fzfcache/
This keeps a history of one command, so its possible that lines from the previous result are included in the current fzf
buffer/cachefile. So, if exact results are very important every time this is run, this probably isn't for you.
As an example:
As some other examples of me using this:
- cache food items (in
cz
) - jump to directories I use often in
cd.zsh
- pick a config file to edit
- pick a config file to send to someone
- search my github stars
Using go install
to put it on your $GOBIN
:
go install github.com/seanbreckenridge/fzfcache@latest
usage: fzfcache [-h] <SHELL COMMAND...>
Caches the input from the shell command and/or prints the cached results
This is typically piped into fzf, to decrease the time till interactive