Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(exa PR) 1196: Update icons to nerd-font-3, replace few icons, handle compressed files separately #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/info/filetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,24 @@ impl FileExtensions {
"build.gradle", "pom.xml", "Rakefile", "package.json", "Gruntfile.js",
"Gruntfile.coffee", "BUILD", "BUILD.bazel", "WORKSPACE", "build.xml", "Podfile",
"webpack.config.js", "meson.build", "composer.json", "RoboFile.php", "PKGBUILD",
"Justfile", "Procfile", "Dockerfile", "Containerfile", "Vagrantfile", "Brewfile",
"Gemfile", "Pipfile", "build.sbt", "mix.exs", "bsconfig.json", "tsconfig.json",
"Justfile", "justfile", "Procfile", "Dockerfile", "Containerfile", "Vagrantfile",
"Brewfile", "Gemfile", "Pipfile", "build.sbt", "mix.exs", "bsconfig.json", "tsconfig.json",
Comment on lines -31 to +32
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

])
}

fn is_image(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"png", "jfi", "jfif", "jif", "jpe", "jpeg", "jpg", "gif", "bmp",
"tiff", "tif", "ppm", "pgm", "pbm", "pnm", "webp", "raw", "arw",
"svg", "stl", "eps", "dvi", "ps", "cbr", "jpf", "cbz", "xpm",
"ico", "cr2", "orf", "nef", "heif", "avif", "jxl", "j2k", "jp2",
"j2c", "jpx",
"png", "jfi", "jfif", "jif", "jpe", "jpeg", "jpg", "gif", "bmp", "tiff",
"tif", "ppm", "pgm", "pbm", "pnm", "webp", "raw", "arw", "svg", "stl", "eps",
"dvi", "ps", "cbr", "jpf", "cbz", "xpm", "ico", "cr2", "orf", "nef",
"heif", "avif", "jxl", "j2k", "jp2", "j2c", "jpx", "pxm",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pxm is the only addition here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is done

])
}

fn is_video(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"avi", "flv", "m2v", "m4v", "mkv", "mov", "mp4", "mpeg",
"mpg", "ogm", "ogv", "vob", "wmv", "webm", "m2ts", "heic",
"mpg", "ogm", "ogv", "vob", "wmv", "webm", "m2ts", "heic", "video",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen this video format before, need example

])
}

Expand Down Expand Up @@ -79,9 +78,10 @@ impl FileExtensions {

fn is_compressed(&self, file: &File<'_>) -> bool {
file.extension_is_one_of( &[
"zip", "tar", "Z", "z", "gz", "bz2", "a", "ar", "7z",
"iso", "dmg", "tc", "rar", "par", "tgz", "xz", "txz",
"lz", "tlz", "lzma", "deb", "rpm", "zst", "lz4", "cpio",
"zip", "tar", "taz", "Z", "z", "gz", "bz", "bz2", "a", "ar",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taz and bz added here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"7z", "iso", "dmg", "tc", "rar", "par", "tgz", "xz", "txz",
"lz", "tlz", "lzma", "deb", "rpm", "zst", "lz4", "cpio", "lzh",
"lzo", "tbz", "tbz2", "tz", "tzo"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"lzh",
"lzo", "tbz", "tbz2", "tz", "tzo"

all seem new

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

])
}

Expand Down Expand Up @@ -137,6 +137,9 @@ impl FileIcon for FileExtensions {
else if self.is_video(file) {
Some(Icons::Video.value())
}
else if self.is_compressed(file) {
Some(Icons::Compressed.value())
}
Comment on lines +140 to +142
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

else {
None
}
Expand Down
116 changes: 33 additions & 83 deletions src/output/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ pub enum Icons {
Audio,
Image,
Video,
Compressed,
}

impl Icons {
pub fn value(self) -> char {
match self {
Self::Audio => '\u{f001}',
Self::Image => '\u{f1c5}',
Self::Video => '\u{f03d}',
Self::Audio => '\u{f001}', // 
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wrong

Self::Image => '\u{f1c5}', // 
Self::Video => '\u{f03d}', // 
Self::Compressed => '\u{f410}', // 
Comment on lines +25 to +28
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}
}
Expand All @@ -48,27 +50,23 @@ pub fn iconify_style(style: Style) -> Style {
lazy_static! {
static ref MAP_BY_NAME: HashMap<&'static str, char> = {
let mut m = HashMap::new();
m.insert(".Trash", '\u{f1f8}'); //
// Icon for specific file name
m.insert(".atom", '\u{e764}'); // 
m.insert(".bashprofile", '\u{e615}'); // 
m.insert(".bashrc", '\u{f489}'); // 
m.insert(".git", '\u{f1d3}'); // 
m.insert(".gitattributes", '\u{f1d3}'); // 
m.insert(".gitconfig", '\u{f1d3}'); // 
m.insert(".github", '\u{f408}'); // 
m.insert(".gitignore", '\u{f1d3}'); // 
m.insert(".gitmodules", '\u{f1d3}'); // 
m.insert("gitignore_global", '\u{f1d3}'); // 
m.insert(".rvm", '\u{e21e}'); // 
m.insert(".vimrc", '\u{e62b}'); // 
m.insert(".vscode", '\u{e70c}'); // 
m.insert(".zshrc", '\u{f489}'); // 
m.insert("Cargo.lock", '\u{e7a8}'); // 
m.insert("bin", '\u{e5fc}'); // 
m.insert("config", '\u{e5fc}'); // 
m.insert("Cargo.lock", '\u{f1617}'); // 󱘗
m.insert("docker-compose.yml", '\u{f308}'); // 
m.insert("Dockerfile", '\u{f308}'); // 
m.insert("ds_store", '\u{f179}'); // 
m.insert("gitignore_global", '\u{f1d3}'); // 
m.insert("go.mod", '\u{e626}'); // 
m.insert("go.sum", '\u{e626}'); // 
m.insert("gradle", '\u{e256}'); // 
Comment on lines -51 to 72
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all from this point should be a separate PR imo

Expand All @@ -78,16 +76,16 @@ lazy_static! {
m.insert("gulpfile.coffee", '\u{e610}'); // 
m.insert("gulpfile.js", '\u{e610}'); // 
m.insert("gulpfile.ls", '\u{e610}'); // 
m.insert("hidden", '\u{f023}'); // 
m.insert("include", '\u{e5fc}'); // 
m.insert("lib", '\u{f121}'); // 
m.insert("localized", '\u{f179}'); // 
m.insert("Makefile", '\u{f489}'); // 
m.insert("node_modules", '\u{e718}'); // 
m.insert("Makefile", '\u{e673}'); // 
m.insert("meson.build", '\u{f013}'); // 
m.insert("meson.options", '\u{f013}'); // 
m.insert("justfile", '\u{f14de}'); // 󱓞
m.insert("npmignore", '\u{e71e}'); // 
m.insert("PKGBUILD", '\u{f303}'); // 
m.insert("rubydoc", '\u{e73b}'); // 
m.insert("yarn.lock", '\u{e718}'); // 
m.insert("yarn.lock", '\u{e6a7}'); // 
m.insert("LICENSE", '\u{f0fc3}'); // 󰿃

m
};
Expand All @@ -99,21 +97,27 @@ pub fn icon_for_file(file: &File<'_>) -> char {
if let Some(icon) = MAP_BY_NAME.get(file.name.as_str()) { *icon }
else if file.points_to_directory() {
match file.name.as_str() {
// Icon for specific folder name
".Trash" => '\u{f1f8}', // 
"bin" => '\u{e5fc}', // 
".git" => '\u{f1d3}', // 
"lib" => '\u{ebdf}', // 
".git" => '\u{e5fb}', // 
".github" => '\u{e5fd}', // 
".idea" => '\u{e7b5}', // 
"node_modules" => '\u{e5fa}', // 
"include" => '\u{e5fc}', // 
"config" => '\u{e5fc}', // 
_ => '\u{f115}' // 
}
}
else if let Some(icon) = extensions.icon_file(file) { icon }
else if let Some(ext) = file.ext.as_ref() {
match ext.as_str() {
// Icon for specific file extension
"ai" => '\u{e7b4}', // 
"android" => '\u{e70e}', // 
"apk" => '\u{e70e}', // 
"apple" => '\u{f179}', // 
"avi" => '\u{f03d}', // 
"avif" => '\u{f1c5}', // 
"avro" => '\u{e60b}', // 
"awk" => '\u{f489}', // 
"bash" => '\u{f489}', // 
Expand All @@ -122,9 +126,6 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"bashrc" => '\u{f489}', // 
"bat" => '\u{f17a}', // 
"bats" => '\u{f489}', // 
"bmp" => '\u{f1c5}', // 
"bz" => '\u{f410}', // 
"bz2" => '\u{f410}', // 
"c" => '\u{e61e}', // 
"c++" => '\u{e61d}', // 
"cab" => '\u{e70f}', // 
Expand All @@ -138,18 +139,17 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"coffee" => '\u{f0f4}', // 
"conf" => '\u{e615}', // 
"cp" => '\u{e61d}', // 
"cpio" => '\u{f410}', // 
"cpp" => '\u{e61d}', // 
"cs" => '\u{f81a}', //
"cs" => '\u{f031b}', // 󰌛
"csh" => '\u{f489}', // 
"cshtml" => '\u{f1fa}', // 
"csproj" => '\u{f81a}', //
"csproj" => '\u{f031b}', // 󰌛
"css" => '\u{e749}', // 
"csv" => '\u{f1c3}', // 
"csx" => '\u{f81a}', //
"csx" => '\u{f031b}', // 󰌛
"cxx" => '\u{e61d}', // 
"d" => '\u{e7af}', // 
"dart" => '\u{e798}', //
"dart" => '\u{e64c}', //
"db" => '\u{f1c0}', // 
"deb" => '\u{e77d}', // 
"diff" => '\u{f440}', // 
Expand All @@ -174,8 +174,6 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"exe" => '\u{f17a}', // 
"exs" => '\u{e62d}', // 
"fish" => '\u{f489}', // 
"flac" => '\u{f001}', // 
"flv" => '\u{f03d}', // 
"font" => '\u{f031}', // 
"fs" => '\u{e7a7}', // 
"fsi" => '\u{e7a7}', // 
Expand All @@ -185,7 +183,6 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"gemfile" => '\u{e21e}', // 
"gemspec" => '\u{e21e}', // 
"gform" => '\u{f298}', // 
"gif" => '\u{f1c5}', // 
"git" => '\u{f1d3}', // 
"gitattributes" => '\u{f1d3}', // 
"gitignore" => '\u{f1d3}', // 
Expand All @@ -196,77 +193,51 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"gsheet" => '\u{f1c3}', // 
"gslides" => '\u{f1c4}', // 
"guardfile" => '\u{e21e}', // 
"gz" => '\u{f410}', // 
"h" => '\u{f0fd}', // 
"hbs" => '\u{e60f}', // 
"hpp" => '\u{f0fd}', // 
"hs" => '\u{e777}', // 
"htm" => '\u{f13b}', // 
"html" => '\u{f13b}', // 
"hxx" => '\u{f0fd}', // 
"ico" => '\u{f1c5}', // 
"image" => '\u{f1c5}', // 
"img" => '\u{e271}', // 
"iml" => '\u{e7b5}', // 
"ini" => '\u{f17a}', // 
"ipynb" => '\u{e606}', // 
"iso" => '\u{e271}', // 
"j2c" => '\u{f1c5}', // 
"j2k" => '\u{f1c5}', // 
"jad" => '\u{e256}', // 
"jar" => '\u{e256}', // 
"java" => '\u{e256}', // 
"jfi" => '\u{f1c5}', // 
"jfif" => '\u{f1c5}', // 
"jif" => '\u{f1c5}', // 
"jl" => '\u{e624}', // 
"jmd" => '\u{f48a}', // 
"jp2" => '\u{f1c5}', // 
"jpe" => '\u{f1c5}', // 
"jpeg" => '\u{f1c5}', // 
"jpg" => '\u{f1c5}', // 
"jpx" => '\u{f1c5}', // 
"js" => '\u{e74e}', // 
"json" => '\u{e60b}', // 
"jsx" => '\u{e7ba}', // 
"jxl" => '\u{f1c5}', // 
"ksh" => '\u{f489}', // 
"latex" => '\u{f034}', // 
"less" => '\u{e758}', // 
"lhs" => '\u{e777}', // 
"license" => '\u{f718}', //
"license" => '\u{f0fc3}', // 󰿃
"localized" => '\u{f179}', // 
"lock" => '\u{f023}', // 
"log" => '\u{f18d}', // 
"lua" => '\u{e620}', // 
"lz" => '\u{f410}', // 
"lz4" => '\u{f410}', // 
"lzh" => '\u{f410}', // 
"lzma" => '\u{f410}', // 
"lzo" => '\u{f410}', // 
"m" => '\u{e61e}', // 
"mm" => '\u{e61d}', // 
"m4a" => '\u{f001}', // 
"markdown" => '\u{f48a}', // 
"md" => '\u{f48a}', // 
"mjs" => '\u{e74e}', // 
"mk" => '\u{f489}', // 
"mkd" => '\u{f48a}', // 
"mkv" => '\u{f03d}', // 
"mobi" => '\u{e28b}', // 
"mov" => '\u{f03d}', // 
"mp3" => '\u{f001}', // 
"mp4" => '\u{f03d}', // 
"msi" => '\u{e70f}', // 
"mustache" => '\u{e60f}', // 
"nix" => '\u{f313}', // 
"node" => '\u{f898}', //
"node" => '\u{e718}', //
"npmignore" => '\u{e71e}', // 
"odp" => '\u{f1c4}', // 
"ods" => '\u{f1c3}', // 
"odt" => '\u{f1c2}', // 
"ogg" => '\u{f001}', // 
"ogv" => '\u{f03d}', // 
"otf" => '\u{f031}', // 
"part" => '\u{f43a}', // 
"patch" => '\u{f440}', // 
Expand All @@ -275,20 +246,17 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"pl" => '\u{e769}', // 
"plx" => '\u{e769}', // 
"pm" => '\u{e769}', // 
"png" => '\u{f1c5}', // 
"pod" => '\u{e769}', // 
"ppt" => '\u{f1c4}', // 
"pptx" => '\u{f1c4}', // 
"procfile" => '\u{e21e}', // 
"properties" => '\u{e60b}', // 
"ps1" => '\u{f489}', // 
"psd" => '\u{e7b8}', // 
"pxm" => '\u{f1c5}', // 
"py" => '\u{e606}', // 
"pyc" => '\u{e606}', // 
"r" => '\u{f25d}', // 
"rakefile" => '\u{e21e}', // 
"rar" => '\u{f410}', // 
"razor" => '\u{f1fa}', // 
"rb" => '\u{e21e}', // 
"rdata" => '\u{f25d}', // 
Expand All @@ -299,12 +267,12 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"rlib" => '\u{e7a8}', // 
"rmd" => '\u{f48a}', // 
"rpm" => '\u{e7bb}', // 
"rs" => '\u{e7a8}', //
"rs" => '\u{f1617}', // 󱘗
"rspec" => '\u{e21e}', // 
"rspec_parallel"=> '\u{e21e}', // 
"rspec_status" => '\u{e21e}', // 
"rss" => '\u{f09e}', // 
"rtf" => '\u{f718}', //
"rtf" => '\u{f0219}', // 󰈙
"ru" => '\u{e21e}', // 
"rubydoc" => '\u{e73b}', // 
"sass" => '\u{e603}', // 
Expand All @@ -320,17 +288,9 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"sty" => '\u{f034}', // 
"styl" => '\u{e600}', // 
"stylus" => '\u{e600}', // 
"svg" => '\u{f1c5}', // 
"swift" => '\u{e755}', // 
"t" => '\u{e769}', // 
"tar" => '\u{f410}', // 
"taz" => '\u{f410}', // 
"tbz" => '\u{f410}', // 
"tbz2" => '\u{f410}', // 
"tex" => '\u{f034}', // 
"tgz" => '\u{f410}', // 
"tiff" => '\u{f1c5}', // 
"tlz" => '\u{f410}', // 
"toml" => '\u{e615}', // 
"torrent" => '\u{e275}', // 
"ts" => '\u{e628}', // 
Expand All @@ -339,16 +299,9 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"ttf" => '\u{f031}', // 
"twig" => '\u{e61c}', // 
"txt" => '\u{f15c}', // 
"txz" => '\u{f410}', // 
"tz" => '\u{f410}', // 
"tzo" => '\u{f410}', // 
"video" => '\u{f03d}', // 
"vim" => '\u{e62b}', // 
"vue" => '\u{fd42}', //
"vue" => '\u{f0844}', // 󰡄
"war" => '\u{e256}', // 
"wav" => '\u{f001}', // 
"webm" => '\u{f03d}', // 
"webp" => '\u{f1c5}', // 
"windows" => '\u{f17a}', // 
"woff" => '\u{f031}', // 
"woff2" => '\u{f031}', // 
Expand All @@ -357,18 +310,15 @@ pub fn icon_for_file(file: &File<'_>) -> char {
"xlsx" => '\u{f1c3}', // 
"xml" => '\u{f121}', // 
"xul" => '\u{f121}', // 
"xz" => '\u{f410}', // 
"yaml" => '\u{f481}', // 
"yml" => '\u{f481}', // 
"zip" => '\u{f410}', // 
"zsh" => '\u{f489}', // 
"zsh-theme" => '\u{f489}', // 
"zshrc" => '\u{f489}', // 
"zst" => '\u{f410}', // 
_ => '\u{f15b}' // 
}
}
else {
'\u{f016}'
'\u{f016}' // 
}
}