Skip to content

Commit 29aab5c

Browse files
committed
added color for symlinks and the symlink destination
1 parent b4499d1 commit 29aab5c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,27 @@ pub fn show_file_name(e: &&std::path::PathBuf, wide_mode: bool) -> Result<(), Bo
278278
} else {
279279
print!(" ");
280280
}
281+
} else if e.symlink_metadata()?.file_type().is_symlink() {
282+
if !colors_on {
283+
print!("{}", color::Fg(color::LightMagenta));
284+
}
285+
print!("{} -> ", Style::new().bold().paint(e.file_name().unwrap().to_str().unwrap()));
286+
if fs::read_link(e)?.is_dir() {
287+
if !colors_on {
288+
print!("{}", color::Fg(color::LightBlue));
289+
}
290+
print!("{}/", fs::read_link(e)?.file_name().unwrap().to_str().unwrap());
291+
} else {
292+
if !colors_on {
293+
print!("{}", color::Fg(color::LightGreen));
294+
}
295+
print!("{}", fs::read_link(e)?.file_name().unwrap().to_str().unwrap());
296+
}
297+
if !wide_mode {
298+
print!("\n");
299+
} else {
300+
print!(" ");
301+
}
281302
} else {
282303
if !colors_on {
283304
print!("{}", color::Fg(color::LightGreen));

0 commit comments

Comments
 (0)