mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 22:22:26 +00:00
Added complete color theming support for Git (#852)
This commit is contained in:
parent
711f661d1e
commit
71156b8530
5 changed files with 74 additions and 3 deletions
|
@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
|
- Add complete color theming support for Git [k4yt3x](https://github.com/k4yt3x]
|
||||||
- Add [Git integration](https://github.com/Peltoche/lsd/issues/7) from [hpwxf](https://github.com/hpwxf)
|
- Add [Git integration](https://github.com/Peltoche/lsd/issues/7) from [hpwxf](https://github.com/hpwxf)
|
||||||
- In keeping with the coreutils change, add quotes and escapes for necessary filenames from [merelymyself](https://github.com/merelymyself)
|
- In keeping with the coreutils change, add quotes and escapes for necessary filenames from [merelymyself](https://github.com/merelymyself)
|
||||||
- Add support for icon theme from [zwpaper](https://github.com/zwpaper)
|
- Add support for icon theme from [zwpaper](https://github.com/zwpaper)
|
||||||
|
|
11
README.md
11
README.md
|
@ -295,6 +295,17 @@ links:
|
||||||
valid: 13
|
valid: 13
|
||||||
invalid: 245
|
invalid: 245
|
||||||
tree-edge: 245
|
tree-edge: 245
|
||||||
|
git-status:
|
||||||
|
default: 245
|
||||||
|
unmodified: 245
|
||||||
|
ignored: 245
|
||||||
|
new-in-index: dark_green
|
||||||
|
new-in-workdir: dark_green
|
||||||
|
typechange: dark_yellow
|
||||||
|
deleted: dark_red
|
||||||
|
renamed: dark_green
|
||||||
|
modified: dark_yellow
|
||||||
|
conflicted: dark_red
|
||||||
```
|
```
|
||||||
|
|
||||||
When creating a theme for `lsd`, you can specify any part of the default theme,
|
When creating a theme for `lsd`, you can specify any part of the default theme,
|
||||||
|
|
32
src/color.rs
32
src/color.rs
|
@ -127,7 +127,37 @@ impl Elem {
|
||||||
Elem::TreeEdge => theme.tree_edge,
|
Elem::TreeEdge => theme.tree_edge,
|
||||||
Elem::Links { valid: false } => theme.links.invalid,
|
Elem::Links { valid: false } => theme.links.invalid,
|
||||||
Elem::Links { valid: true } => theme.links.valid,
|
Elem::Links { valid: true } => theme.links.valid,
|
||||||
Elem::GitStatus { .. } => theme.git_status.default,
|
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Default,
|
||||||
|
} => theme.git_status.default,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Unmodified,
|
||||||
|
} => theme.git_status.unmodified,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Ignored,
|
||||||
|
} => theme.git_status.ignored,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::NewInIndex,
|
||||||
|
} => theme.git_status.new_in_index,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::NewInWorkdir,
|
||||||
|
} => theme.git_status.new_in_workdir,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Typechange,
|
||||||
|
} => theme.git_status.typechange,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Deleted,
|
||||||
|
} => theme.git_status.deleted,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Renamed,
|
||||||
|
} => theme.git_status.renamed,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Modified,
|
||||||
|
} => theme.git_status.modified,
|
||||||
|
Elem::GitStatus {
|
||||||
|
status: GitStatus::Conflicted,
|
||||||
|
} => theme.git_status.conflicted,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,9 @@ impl GitCache {
|
||||||
match std::fs::canonicalize(filepath) {
|
match std::fs::canonicalize(filepath) {
|
||||||
Ok(filename) => Some(self.inner_get(&filename, is_directory)),
|
Ok(filename) => Some(self.inner_get(&filename, is_directory)),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
if err.kind() != std::io::ErrorKind::NotFound {
|
||||||
crate::print_error!("Cannot get git status for {:?}: {}", filepath, err);
|
crate::print_error!("Cannot get git status for {:?}: {}", filepath, err);
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,24 @@ pub struct Links {
|
||||||
pub struct GitStatus {
|
pub struct GitStatus {
|
||||||
#[serde(deserialize_with = "deserialize_color")]
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
pub default: Color,
|
pub default: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub unmodified: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub ignored: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub new_in_index: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub new_in_workdir: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub typechange: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub deleted: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub renamed: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub modified: Color,
|
||||||
|
#[serde(deserialize_with = "deserialize_color")]
|
||||||
|
pub conflicted: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Permission {
|
impl Default for Permission {
|
||||||
|
@ -337,7 +355,16 @@ impl Default for Links {
|
||||||
impl Default for GitStatus {
|
impl Default for GitStatus {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
GitStatus {
|
GitStatus {
|
||||||
default: Color::AnsiValue(13), // Pink
|
default: Color::AnsiValue(245), // Grey
|
||||||
|
unmodified: Color::AnsiValue(245), // Grey
|
||||||
|
ignored: Color::AnsiValue(245), // Grey
|
||||||
|
new_in_index: Color::DarkGreen,
|
||||||
|
new_in_workdir: Color::DarkGreen,
|
||||||
|
typechange: Color::DarkYellow,
|
||||||
|
deleted: Color::DarkRed,
|
||||||
|
renamed: Color::DarkGreen,
|
||||||
|
modified: Color::DarkYellow,
|
||||||
|
conflicted: Color::DarkRed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue