From a542fdc9f98a801a76bada9056f72aa469e353a9 Mon Sep 17 00:00:00 2001 From: Ben S Date: Sat, 21 Jun 2014 18:17:24 +0100 Subject: [PATCH] Highlight symlinks in cyan --- file.rs | 4 ++-- filetype.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/file.rs b/file.rs index e8c30d6..daa5fb6 100644 --- a/file.rs +++ b/file.rs @@ -1,4 +1,4 @@ -use colours::{Plain, Style, Black, Red, Green, Yellow, Blue, Purple, Cyan}; +use colours::{Plain, Style, Black, Red, Green, Yellow, Blue, Purple, Cyan, Fixed}; use std::io::{fs, IoResult}; use std::io; @@ -110,7 +110,7 @@ impl<'a> File<'a> { let displayed_name = self.file_colour().paint(self.name); if self.stat.kind == io::TypeSymlink { match fs::readlink(self.path) { - Ok(path) => format!("{} => {}", displayed_name, path.display()), + Ok(path) => format!("{} {} {}", displayed_name, Fixed(244).paint("=>"), path.display()), Err(e) => { println!("{}", e); displayed_name diff --git a/filetype.rs b/filetype.rs index 3c906e5..1d44901 100644 --- a/filetype.rs +++ b/filetype.rs @@ -1,9 +1,9 @@ -use colours::{Plain, Style, Red, Green, Yellow, Blue, Fixed}; +use colours::{Plain, Style, Red, Green, Yellow, Blue, Cyan, Fixed}; use file::File; use std::io; pub enum FileType { - Normal, Directory, Executable, Immediate, Compiled, + Normal, Directory, Executable, Immediate, Compiled, Symlink, Image, Video, Music, Lossless, Compressed, Document, Temp, Crypto, } @@ -45,6 +45,7 @@ impl FileType { match *self { Normal => Plain, Directory => Blue.bold(), + Symlink => Cyan.normal(), Executable => Green.bold(), Image => Fixed(133).normal(), Video => Fixed(135).normal(), @@ -69,6 +70,9 @@ impl<'a> HasType for File<'a> { if self.stat.kind == io::TypeDirectory { return Directory; } + else if self.stat.kind == io::TypeSymlink { + return Symlink; + } else if self.stat.perm.contains(io::UserExecute) { return Executable; } -- GitLab