docs: add README for default configuration files

This commit is contained in:
sxyazi 2024-12-07 02:09:51 +08:00
parent 9d3c0c72fe
commit 125133268b
No known key found for this signature in database
5 changed files with 40 additions and 4 deletions

View file

@ -150,7 +150,7 @@ impl Emulator {
}
fn cell_size(resp: &str) -> Option<(u16, u16)> {
let b = resp.split_at(resp.find("\x1b[6;")? + 4).1.as_bytes();
let b = resp.split_once("\x1b[6;")?.1.as_bytes();
let h: Vec<_> = b.iter().copied().take_while(|&c| c.is_ascii_digit()).collect();
b.get(h.len()).filter(|&&c| c == b';')?;

View file

@ -0,0 +1,31 @@
# Yazi Default Configuration
This directory contains the default configuration files for Yazi:
- [`yazi-default.toml`][yazi-default]: General configuration
- [`keymap-default.toml`][keymap-default]: Keybindings configuration
- [`theme-dark.toml`][theme-dark]: Dark color scheme configuration (loaded when your terminal is in dark mode)
- [`theme-light.toml`][theme-light]: Light color scheme configuration (loaded when your terminal is in light mode)
These files are already included with Yazi when you install the release, so you don't need to manually download or copy them to your Yazi configuration directory.
However, if you want to customize certain configurations:
- Create a `yazi.toml` in your config directory to override the settings in [`yazi-default.toml`][yazi-default], so either:
- `~/.config/yazi/yazi.toml` on Unix-like systems
- `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` on Windows
- Create a `keymap.toml` in your config directory to override the settings in [`keymap-default.toml`][keymap-default], so either:
- `~/.config/yazi/keymap.toml` on Unix-like systems
- `C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml` on Windows
- Create a `theme.toml` in your config directory to override the settings in [`theme-light.toml`][theme-light] and [`theme-dark.toml`][theme-dark], so either:
- `~/.config/yazi/theme.toml` on Unix-like systems
- `C:\Users\USERNAME\AppData\Roaming\yazi\config\theme.toml` on Windows
For the user's `theme.toml` file, you can only apply the same color scheme to both the light and dark themes.
If you want more granular control over colors, specify two different flavors for light and dark modes under the `[flavor]` section of your `theme.toml`, and override them there instead.
[yazi-default]: yazi-default.toml
[keymap-default]: keymap-default.toml
[theme-dark]: theme-dark.toml
[theme-light]: theme-light.toml

View file

@ -4,8 +4,13 @@ macro_rules! config_preset {
#[cfg(debug_assertions)]
{
std::borrow::Cow::from(
std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/preset/", $name, ".toml"))
.expect(concat!("Failed to read 'yazi-config/preset/", $name, ".toml'")),
std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/preset/",
$name,
"-default.toml"
))
.expect(concat!("Failed to read 'yazi-config/preset/", $name, "-default.toml'")),
)
}
#[cfg(not(debug_assertions))]
@ -14,7 +19,7 @@ macro_rules! config_preset {
env!("CARGO_MANIFEST_DIR"),
"/preset/",
$name,
".toml"
"-default.toml"
)))
}
}};