ogham / exa

A modern replacement for ‘ls’.
https://the.exa.website/
MIT License
23.64k stars 661 forks source link

Add option to print current colors in LS_COLORS and EXA_COLORS format #544

Open dandavison opened 5 years ago

dandavison commented 5 years ago

Would it make sense to add options like --print-ls-colors and --print-exa-colors that prints out all the colors that exa is currently using, in the correct format to be used as a value for $LS_COLORS and $EXA_COLORS. I'm thinking that this would then be a convenient way for a user to quickly tweak exa's colors.

For example, I'm using a white terminal background and exa is emitting a yellow color that I can't read. With these options I could generate an LS_COLORS or EXA_COLORS string, and then quickly replace the yellow color code with something else, for all the file types / UI elements where the yellow occurs.

lilyball commented 5 years ago

The built-in extensions are documented in the manpage. A problem with what you're proposing is any additions made to the set wouldn't be contained in the old --print-exa-colors output and therefore wouldn't obey the override.

Looking at the manpage right now, the biggest issues I see with overriding are the fact that "Immediate" files and Compiled files aren't fully-defined classes, so I can't write a rule to cover all of those right now. Perhaps exa should have a special EXA_COLORS token for changing the color of "Immediate" files or compiled files.

smhmd commented 4 years ago

@lilyball How do we otherwise print $EXA_COLORS? I happen to not have that env variable, and I would like to use it in $LS_COLORS's stead. image

lilyball commented 4 years ago

@alivefromupstairs I'm not sure what you mean. If you're using LS_COLORS already you can just set EXA_COLORS to the same thing, and then start adding in any exa customizations you want. If you don't have either variable set, consult the manpage to see what the defaults are.

smhmd commented 4 years ago

The manpage does not list the values of each, but instructions and general description:

// From man exa
       • Images (png, jpeg, gif) are purple.

       • Videos (mp4, ogv, m2ts) are a slightly purpler purple.

       • Music (mp3, m4a, ogg) is a deeper purple.

       • Lossless music (flac, alac, wav) is deeper than that purple.  In general, most media files are some
         shade of purple.

       • Cryptographic files (asc, enc, p12) are a faint blue.

       • Documents (pdf, doc, dvi) are a less faint blue.

       • Compressed files (zip, tgz, Z) are red.

       • Temporary files (tmp, swp, ~) are grey.

or have I overlooked something?

I am trying to fix up LS_COLORS through dircolors and I think I'm getting the hang of it. But how can I determin what exa's man page refers to as "a slightly purpler purple"?

Mte90 commented 4 years ago

There are any updates? I want that LS_COLORS it is the same of EXA_COLORS because I have some tools that used that variable.

TonioGela commented 2 years ago

+1 on this.

infused-kim commented 2 years ago

I faced the same problem.

You can find the default colors in these files: https://github.com/ogham/exa/blob/master/src/theme/default_theme.rs https://github.com/ogham/exa/blob/master/src/info/filetype.rs

Based on them, I created an LS_COLORS export:

export LS_COLORS="di=1;34:ln=0;36:pi=0;33:bd=1;33:cd=1;33:so=1;31:ex=1;32:*README=1;4;33:*README.txt=1;4;33:*README.md=1;4;33:*readme.txt=1;4;33:*readme.md=1;4;33:*.ninja=1;4;33:*Makefile=1;4;33:*Cargo.toml=1;4;33:*SConstruct=1;4;33:*CMakeLists.txt=1;4;33:*build.gradle=1;4;33:*pom.xml=1;4;33:*Rakefile=1;4;33:*package.json=1;4;33:*Gruntfile.js=1;4;33:*Gruntfile.coffee=1;4;33:*BUILD=1;4;33:*BUILD.bazel=1;4;33:*WORKSPACE=1;4;33:*build.xml=1;4;33:*Podfile=1;4;33:*webpack.config.js=1;4;33:*meson.build=1;4;33:*composer.json=1;4;33:*RoboFile.php=1;4;33:*PKGBUILD=1;4;33:*Justfile=1;4;33:*Procfile=1;4;33:*Dockerfile=1;4;33:*Containerfile=1;4;33:*Vagrantfile=1;4;33:*Brewfile=1;4;33:*Gemfile=1;4;33:*Pipfile=1;4;33:*build.sbt=1;4;33:*mix.exs=1;4;33:*bsconfig.json=1;4;33:*tsconfig.json=1;4;33:*.zip=0;31:*.tar=0;31:*.Z=0;31:*.z=0;31:*.gz=0;31:*.bz2=0;31:*.a=0;31:*.ar=0;31:*.7z=0;31:*.iso=0;31:*.dmg=0;31:*.tc=0;31:*.rar=0;31:*.par=0;31:*.tgz=0;31:*.xz=0;31:*.txz=0;31:*.lz=0;31:*.tlz=0;31:*.lzma=0;31:*.deb=0;31:*.rpm=0;31:*.zst=0;31:*.lz4=0;31"

If you'd like to adjust the colors, you can use this python script: https://gist.github.com/infused-kim/5b95ef5a4a49dda96e50c1fa4ce793eb

Mte90 commented 2 years ago

I use https://github.com/trapd00r/LS_COLORS that has a lot of more files...

richardswesterhof commented 2 years ago

Any update on this? The LS_COLORS export mentioned earlier doesn't cover all colors exa uses. A great usecase for such a feature would be making ls (or any other program that uses the LS_COLORS variable) use the same colors as exa does, which is great for consistency

ariasuni commented 2 years ago

You could dynamically set EXA_COLORS to LS_COLORS + the specific code exa uses, as a workaround.

richardswesterhof commented 2 years ago

Thanks, but the problem is that the colors that exa uses can't be found explicitly. However, using the documentation and creating files with exa's known filetypes myself and seeing which color codes exa generates for each, I came up with this:

export LS_COLORS="*.arw=38;5;133:*.bmp=38;5;133:*.cbr=38;5;133:*.cbz=38;5;133:*.cr2=38;5;133:*.dvi=38;5;133:*.eps=38;5;133:*.gif=38;5;133:*.heif=38;5;133:*.ico=38;5;133:*.jpeg=38;5;133:*.jpg=38;5;133:*.nef=38;5;133:*.orf=38;5;133:*.pbm=38;5;133:*.pgm=38;5;133:*.png=38;5;133:*.pnm=38;5;133:*.ppm=38;5;133:*.ps=38;5;133:*.raw=38;5;133:*.stl=38;5;133:*.svg=38;5;133:*.tif=38;5;133:*.tiff=38;5;133:*.webp=38;5;133:*.xpm=38;5;133:*.avi=38;5;135:*.flv=38;5;135:*.heic=38;5;135:*.m2ts=38;5;135:*.m2v=38;5;135:*.mkv=38;5;135:*.mov=38;5;135:*.mp4=38;5;135:*.mpeg=38;5;135:*.mpg=38;5;135:*.ogm=38;5;135:*.ogv=38;5;135:*.ts=38;5;135:*.vob=38;5;135:*.webm=38;5;135:*.wmvm=38;5;135:*.djvu=38;5;105:*.doc=38;5;105:*.docx=38;5;105:*.dvi=38;5;105:*.eml=38;5;105:*.eps=38;5;105:*.fotd=38;5;105:*.key=38;5;105:*.odp=38;5;105:*.odt=38;5;105:*.pdf=38;5;105:*.ppt=38;5;105:*.pptx=38;5;105:*.rtf=38;5;105:*.xls=38;5;105:*.xlsx=38;5;105:*.aac=38;5;92:*.alac=38;5;92:*.ape=38;5;92:*.flac=38;5;92:*.m4a=38;5;92:*.mka=38;5;92:*.mp3=38;5;92:*.ogg=38;5;92:*.opus=38;5;92:*.wav=38;5;92:*.wma=38;5;92:*.7z=31:*.a=31:*.ar=31:*.bz2=31:*.deb=31:*.dmg=31:*.gz=31:*.iso=31:*.lzma=31:*.par=31:*.rar=31:*.rpm=31:*.tar=31:*.tc=31:*.tgz=31:*.txz=31:*.xz=31:*.z=31:*.Z=31:*.zip=31:*.zst=31:*.asc=38;5;109:*.enc=38;5;109:*.gpg=38;5;109:*.p12=38;5;109:*.pfx=38;5;109:*.pgp=38;5;109:*.sig=38;5;109:*.signature=38;5;109:*.bak=38;5;244:*.bk=38;5;244:*.swn=38;5;244:*.swo=38;5;244:*.swp=38;5;244:*.tmp=38;5;244:*.~=38;5;244:pi=33:cd=33:bd=33:di=34;1:so=36:or=36:ln=36:ex=32;1:"

Note that ls didn't seem to like plain filenames instead of patterns, so I left those out (for the "immediate files" category)