Skip to content

Commit

Permalink
theme: 🔨 use themes dir for themes configurations
Browse files Browse the repository at this point in the history
Signed-off-by: zwPapEr <[email protected]>
  • Loading branch information
zwpaper committed Aug 31, 2021
1 parent 47a7714 commit 4d4dab7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ color:
when: auto
# How to colorize the output.
# When "classic" is set, this is set to "no-color".
# Possible values: default, no-color, no-lscolors, <theme-file-name>
# when specifying <theme-file-name>, lsd will look up theme file in
# XDG Base Directory if relative
# Possible values: default, <theme-file-name>
# when specifying <theme-file-name>, lsd will look up theme file
# XDG Base Directory if relative, e.g. ~/.config/lsd/themes/<theme-file-name>,
# The file path if absolute
theme: default

Expand Down Expand Up @@ -322,7 +322,7 @@ The valid theme configurations are:

when configured with the `theme-file-name` which is a `yaml` file,
`lsd` will look up the theme file in the following way:
- relative name: check the XDG Base Directory
- relative name: check the themes under XDG Base Directory, e.g. ~/.config/lsd/themes/<theme-file-name>
- absolute name: use the file path and name to find theme file

Check [Theme file content](#theme-file-content) for details.
Expand Down
5 changes: 2 additions & 3 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ impl Colors {
ThemeOption::NoColor => None,
ThemeOption::Default => Some(Theme::default()),
ThemeOption::NoLscolors => Some(Theme::default()),
ThemeOption::Custom(ref file) => {
Some(Theme::from_path(file).unwrap_or_else(Theme::default))
}
ThemeOption::Custom(ref file) => Some(Theme::from_path(file).unwrap_or_default()),
};
let lscolors = match t {
ThemeOption::Default => Some(LsColors::from_env().unwrap_or_default()),
ThemeOption::Custom(_) => Some(LsColors::from_env().unwrap_or_default()),
_ => None,
};

Expand Down
2 changes: 1 addition & 1 deletion src/color/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl Theme {
let path = if Path::new(&real).is_absolute() {
real
} else {
config_file::Config::config_file_path().unwrap().join(real)
config_file::Config::config_file_path()?.join("themes").join(real)
};
match fs::read(&path) {
Ok(f) => match Self::with_yaml(&String::from_utf8_lossy(&f)) {
Expand Down
11 changes: 1 addition & 10 deletions src/flags/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,7 @@ pub enum IconTheme {
Fancy,
}

impl IconTheme {
// /// Get a value from a string.
// fn from_str(value: &str) -> Option<Self> {
// match value {
// "fancy" => Some(Self::Fancy),
// "unicode" => Some(Self::Unicode),
// _ => panic!("Bad icons.theme config, {}", &value),
// }
// }
}
impl IconTheme {}

impl Configurable<Self> for IconTheme {
/// Get a potential `IconTheme` variant from [ArgMatches].
Expand Down
1 change: 0 additions & 1 deletion src/flags/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use serde::Deserialize;
pub enum Layout {
Grid,
Tree,
#[serde(rename = "oneline")]
OneLine,
}

Expand Down
2 changes: 1 addition & 1 deletion src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ impl Meta {
}
}

#[cfg(unix)]
#[cfg(test)]
mod tests {
use super::Meta;

#[test]
#[cfg(unix)]
fn test_from_path_path() {
let dir = assert_fs::TempDir::new().unwrap();
let meta = Meta::from_path(dir.path(), false).unwrap();
Expand Down

0 comments on commit 4d4dab7

Please sign in to comment.