Skip to content
Myr

Highlight executable files

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent 8adb5b9 · Browse files · 4 files+17 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+17 added−2 removed

  • other:+17 added−2 removed

4 files+17 added−2 removed

modified:src/lscolors/mod.rs+5 added
22 unmodified lines
2324 /// ANSI style for symbolic links.25 pub symlink: Style,2627 /// ANSI style for executable files.28 pub executable: Style,2930 /// A map that defines ANSI styles for different file extensions.31 pub extensions: ExtensionStyles,3233 /// A map that defines ANSI styles for different specific filenames.
5 unmodified lines
39 fn default() -> LsColors {40 LsColors {41 directory: Colour::Blue.bold(),42 symlink: Colour::Cyan.normal(),43 executable: Colour::Red.bold(),44 extensions: HashMap::new(),45 filenames: HashMap::new()46 }47 }
80 unmodified lines
128 if let Some(code) = res {129 match code.as_ref() {130 "di" => self.directory = style,131 "ln" => self.symlink = style,132 "ex" => self.executable = style,133 _ => return134 }135 } else if pattern.starts_with("*.") {136 let extension = String::from(pattern).split_off(2);
83 unmodified lines
modified:src/main.rs+10 added
10 unmodified lines
11use std::error::Error;12use std::ffi::OsStr;13use std::fs;14use std::io::Write;15use std::os::unix::fs::PermissionsExt;16use std::path::{Path, Component};17use std::process;1819use getopts::Options;
56 unmodified lines
76 Some(p) => p,77 None => return78 };7980 let is_executable = |p: &std::path::PathBuf| {81 p.metadata()82 .ok()83 .map(|f| f.permissions().mode() & 0o111 != 0)84 .unwrap_or(false)85 };8687 if let Some(ref ls_colors) = config.ls_colors {88 let mut component_path = base.to_path_buf();8990 if config.path_display == PathDisplay::Absolute {
16 unmodified lines
107 .unwrap_or(false) {108 ls_colors.symlink109 } else if component_path.is_dir() {110 ls_colors.directory111 } else if is_executable(&component_path) {112 ls_colors.executable113 } else {114 // Look up file name115 let o_style =116 component_path.file_name()
176 unmodified lines
modified:Cargo.lock+1 added-1 removed
1[root]2name = "fd"3version = "0.3.0"3version = "1.0.0"4dependencies = [5 "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",6 "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",7 "ignore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
208 unmodified lines
modified:Cargo.toml+1 added-1 removed