-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify a directory for cache #829
Comments
There is likely a better way to do this. Revert once given feedback in sharkdp/bat#829.
The cache directory is determined in this file, and currently isn't configurable outside of setting the It wouldn't be difficult to make it configurable through a command line argument, but if you're looking for a quick and easy workaround: #!/usr/bin/env bash
export XDG_CACHE_HOME="${HOME}/config"
/usr/bin/bat "$@" Saving that as |
@eth-p That would work but I prefer not to touch # Setup bat cache files.
if [[ -f "$HOME/.local/share/bat/themes.bin" ]] && [[ -f "$HOME/.local/share/bat/syntaxes.bin" ]]; then
mkdir "$HOME/.cache/bat"
cp "$HOME/.local/share/bat/themes.bin" "$HOME/.cache/bat"
cp "$HOME/.local/share/bat/syntaxes.bin" "$HOME/.cache/bat"
fi |
That also works, yeah. If you're not adverse to the wrapper idea though, you could add it as a wrapper function in your |
@eth-p Good point. I'll try that instead. |
Let me know how that works out. If it's still not ideal, one of us could still add a configuration option for it! The only downside would be that you would have to build bat from master or wait for a new release if we go down that route, though. |
@eth-p I would still greatly appreciate if this option was added. I see my current solution and your wrapper idea above as workaround. I have no problem waiting for a release or just building it from source myself. |
Hello, I would like to take this issue if its available. |
Is the desired outcome to be able to specify the cache dir via a command line option? My understanding after inspecting the code, is that this cache dir is referenced early on in the processes' runtime and is currently initialized as a member of an immutable lazy_static. Additionally, the cache_dir is referenced in later executions of bat after its been set up. So we would have to store that user-specified cache dir location somewhere, and the config file makes more sense to me than an environment variable. What I'm thinking is we could read the config file first and check for an entry for cache_dir. |
In
Yes, that's a problem. We do this because we need to reference the config directory before parsing the command-line options, as the config entries go first (and can be overwritten by command-line options). An environment variable |
@sharkdp Thanks for the insights! |
Sounds great |
This has been released in bat 0.13. |
Hey 👋,
I have my
.cache
directory set astmpfs
to run all cache related files on RAM. This makes the.cache
available only per session which is an issue withbat
as the built custom themes I have are removed.Is there a way to specify a directory for
bat
to load theme and syntax from? I've triedbat cache --source ~/.local/share/bat
but that just creates the cache at that location. I see no option to load the cache from that place.The text was updated successfully, but these errors were encountered: