mirror of
https://github.com/lsd-rs/lsd
synced 2024-11-10 06:14:19 +00:00
🔨 use lscolors for filename only, skip from theme configure
Signed-off-by: zwPapEr <zw.paper@gmail.com>
This commit is contained in:
parent
861822cb04
commit
9f656fdd9d
3 changed files with 31 additions and 63 deletions
29
README.md
29
README.md
|
@ -327,12 +327,6 @@ when configured with the `theme-file-name` which is a `yaml` file,
|
|||
|
||||
Check [Theme file content](#theme-file-content) for details.
|
||||
|
||||
### Filename coloring
|
||||
|
||||
`lsd` use both [LS_COLORS](https://github.com/trapd00r/LS_COLORS) and this theme feature to
|
||||
colorize the filename, `lsd` will use the color and format option defined in `LS_COLORS`,
|
||||
and then the theme configurations if no `LS_COLOR` are found.
|
||||
|
||||
### Theme file content
|
||||
|
||||
Theme file use the [crossterm](https://crates.io/crates/crossterm)
|
||||
|
@ -348,30 +342,13 @@ This is the default theme scheme shipped with `lsd`.
|
|||
```yaml
|
||||
user: 230
|
||||
group: 187
|
||||
permissions:
|
||||
permission:
|
||||
read: Green
|
||||
write: Yellow
|
||||
exec: Red
|
||||
exec-sticky: 5
|
||||
no-access: 245
|
||||
file-type:
|
||||
file:
|
||||
exec-uid: 40
|
||||
uid-no-exec: 184
|
||||
exec-no-uid: 40
|
||||
no-exec-no-uid: 184
|
||||
dir:
|
||||
uid: 33
|
||||
no-uid: 33
|
||||
pipe: 44
|
||||
symlink:
|
||||
default: 44
|
||||
broken: 124
|
||||
block-device: 44
|
||||
char-device: 172
|
||||
socket: 44
|
||||
special: 44
|
||||
modified:
|
||||
date:
|
||||
hour-old: 40
|
||||
day-old: 42
|
||||
older: 36
|
||||
|
@ -427,7 +404,7 @@ Some further examples of useful aliases:
|
|||
In the future the possibility to customize the colors might be implemented.
|
||||
For now, the default colors are:
|
||||
|
||||
| User/Group | Permissions | File Types | Last time Modified | File Size |
|
||||
| User/Group | Permission | File Types | Date | File Size |
|
||||
|:---|:---|:---|:---|:---|
|
||||
|![#ffffd7](https://via.placeholder.com/15/ffffd7/000000?text=+) User|![#00d700](https://via.placeholder.com/15/00d700/000000?text=+) Read |![#0087ff](https://via.placeholder.com/15/0087ff/000000?text=+) Directory|![#00d700](https://via.placeholder.com/15/00d700/000000?text=+) within the last hour|![#ffffaf](https://via.placeholder.com/15/ffffaf/000000?text=+) Small File|
|
||||
|![#d7d7af](https://via.placeholder.com/15/d7d7af/000000?text=+) Group|![#d7ff87](https://via.placeholder.com/15/d7ff87/000000?text=+) Write|![#00d700](https://via.placeholder.com/15/00d700/000000?text=+) Executable File|![#00d787](https://via.placeholder.com/15/00d787/000000?text=+) within the last day|![#ffaf87](https://via.placeholder.com/15/ffaf87/000000?text=+) Medium File|
|
||||
|
|
22
src/color.rs
22
src/color.rs
|
@ -28,7 +28,7 @@ pub enum Elem {
|
|||
Socket,
|
||||
Special,
|
||||
|
||||
/// Permissions
|
||||
/// Permission
|
||||
Read,
|
||||
Write,
|
||||
Exec,
|
||||
|
@ -95,15 +95,15 @@ impl Elem {
|
|||
Elem::Socket => theme.file_type.socket,
|
||||
Elem::Special => theme.file_type.special,
|
||||
|
||||
Elem::Read => theme.permissions.read,
|
||||
Elem::Write => theme.permissions.write,
|
||||
Elem::Exec => theme.permissions.exec,
|
||||
Elem::ExecSticky => theme.permissions.exec_sticky,
|
||||
Elem::NoAccess => theme.permissions.no_access,
|
||||
Elem::Read => theme.permission.read,
|
||||
Elem::Write => theme.permission.write,
|
||||
Elem::Exec => theme.permission.exec,
|
||||
Elem::ExecSticky => theme.permission.exec_sticky,
|
||||
Elem::NoAccess => theme.permission.no_access,
|
||||
|
||||
Elem::DayOld => theme.modified.day_old,
|
||||
Elem::HourOld => theme.modified.hour_old,
|
||||
Elem::Older => theme.modified.older,
|
||||
Elem::DayOld => theme.date.day_old,
|
||||
Elem::HourOld => theme.date.hour_old,
|
||||
Elem::Older => theme.date.older,
|
||||
|
||||
Elem::User => theme.user,
|
||||
Elem::Group => theme.group,
|
||||
|
@ -325,7 +325,7 @@ mod elem {
|
|||
Theme {
|
||||
user: Color::AnsiValue(230), // Cornsilk1
|
||||
group: Color::AnsiValue(187), // LightYellow3
|
||||
permissions: theme::Permissions {
|
||||
permission: theme::Permission {
|
||||
read: Color::Green,
|
||||
write: Color::Yellow,
|
||||
exec: Color::Red,
|
||||
|
@ -353,7 +353,7 @@ mod elem {
|
|||
socket: Color::AnsiValue(44), // DarkTurquoise
|
||||
special: Color::AnsiValue(44), // DarkTurquoise
|
||||
},
|
||||
modified: theme::Modified {
|
||||
date: theme::Date {
|
||||
hour_old: Color::AnsiValue(40), // Green3
|
||||
day_old: Color::AnsiValue(42), // SpringGreen2
|
||||
older: Color::AnsiValue(36), // DarkCyan
|
||||
|
|
|
@ -16,19 +16,21 @@ use std::path::Path;
|
|||
pub struct Theme {
|
||||
pub user: Color,
|
||||
pub group: Color,
|
||||
pub permissions: Permissions,
|
||||
pub file_type: FileType,
|
||||
pub modified: Modified,
|
||||
pub permission: Permission,
|
||||
pub date: Date,
|
||||
pub size: Size,
|
||||
pub inode: INode,
|
||||
pub tree_edge: Color,
|
||||
pub links: Links,
|
||||
|
||||
#[serde(skip)]
|
||||
pub file_type: FileType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Permissions {
|
||||
pub struct Permission {
|
||||
pub read: Color,
|
||||
pub write: Color,
|
||||
pub exec: Color,
|
||||
|
@ -79,7 +81,7 @@ pub struct Symlink {
|
|||
#[derive(Debug, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Modified {
|
||||
pub struct Date {
|
||||
pub hour_old: Color,
|
||||
pub day_old: Color,
|
||||
pub older: Color,
|
||||
|
@ -111,6 +113,12 @@ pub struct Links {
|
|||
pub invalid: Color,
|
||||
}
|
||||
|
||||
impl Default for FileType {
|
||||
fn default() -> Self {
|
||||
Theme::default_dark().file_type
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Theme {
|
||||
fn default() -> Self {
|
||||
// TODO(zwpaper): check terminal color and return light or dark
|
||||
|
@ -161,7 +169,7 @@ impl Theme {
|
|||
Theme {
|
||||
user: Color::AnsiValue(230), // Cornsilk1
|
||||
group: Color::AnsiValue(187), // LightYellow3
|
||||
permissions: Permissions {
|
||||
permission: Permission {
|
||||
read: Color::Green,
|
||||
write: Color::Yellow,
|
||||
exec: Color::Red,
|
||||
|
@ -189,7 +197,7 @@ impl Theme {
|
|||
socket: Color::AnsiValue(44), // DarkTurquoise
|
||||
special: Color::AnsiValue(44), // DarkTurquoise
|
||||
},
|
||||
modified: Modified {
|
||||
date: Date {
|
||||
hour_old: Color::AnsiValue(40), // Green3
|
||||
day_old: Color::AnsiValue(42), // SpringGreen2
|
||||
older: Color::AnsiValue(36), // DarkCyan
|
||||
|
@ -217,30 +225,13 @@ impl Theme {
|
|||
r#"---
|
||||
user: 230
|
||||
group: 187
|
||||
permissions:
|
||||
permission:
|
||||
read: Green
|
||||
write: Yellow
|
||||
exec: Red
|
||||
exec-sticky: 5
|
||||
no-access: 245
|
||||
file-type:
|
||||
file:
|
||||
exec-uid: 40
|
||||
uid-no-exec: 184
|
||||
exec-no-uid: 40
|
||||
no-exec-no-uid: 184
|
||||
dir:
|
||||
uid: 33
|
||||
no-uid: 33
|
||||
pipe: 44
|
||||
symlink:
|
||||
default: 44
|
||||
broken: 124
|
||||
block-device: 44
|
||||
char-device: 172
|
||||
socket: 44
|
||||
special: 44
|
||||
modified:
|
||||
date:
|
||||
hour-old: 40
|
||||
day-old: 42
|
||||
older: 36
|
||||
|
|
Loading…
Reference in a new issue