Skip to content

Commit

Permalink
Merge pull request #15 from triyanox/feat/enhance-dir-items
Browse files Browse the repository at this point in the history
feat: add directory indicator #11
  • Loading branch information
chaqchase authored Nov 27, 2024
2 parents e7c66c0 + d72d6ad commit 503a2c0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lla/src/utils/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::Path;
pub fn colorize_file_name(path: &Path) -> ColoredString {
let name = path.file_name().unwrap().to_str().unwrap();
if path.is_dir() {
name.bright_blue().bold()
format!("{}/", name).bright_blue().bold()
} else if path.is_symlink() {
name.bright_cyan().italic()
} else if is_executable(path) {
Expand Down Expand Up @@ -39,10 +39,15 @@ use std::os::unix::fs::PermissionsExt;

pub fn colorize_permissions(permissions: &Permissions) -> String {
let mode = permissions.mode();
let file_type = if mode & 0o40000 != 0 {
"d".bright_blue()
} else {
"-".bright_black()
};
let user = triplet(mode, 6);
let group = triplet(mode, 3);
let other = triplet(mode, 0);
format!("{}{}{}", user, group, other)
format!("{}{}{}{}", file_type, user, group, other)
}

fn triplet(mode: u32, shift: u32) -> String {
Expand Down

0 comments on commit 503a2c0

Please sign in to comment.