inputs: { config, lib, ... }: { programs.bash.enableLsColors = false; home-manager.users.minijackson = {config, ...}: { # Due to GRML calling dircolors, despite the fact that LS_COLORS is already # defined programs.zsh.initExtra = '' ${lib.toShellVar "LS_COLORS" config.home.sessionVariables.LS_COLORS} zstyle ':completion:*:default' list-colors ''${(s.:.)LS_COLORS} ''; # TODO: this is not really compatible with 'ls', and hence not compatible # with other tools e.g. bash home.sessionVariables.LS_COLORS = let ls_colors = set: lib.concatStringsSep ":" (lib.mapAttrsToList (key: value: "${key}=${value}") set); bold = "01"; underline = "04"; red = "31"; green = "32"; yellow = "33"; blue = "34"; purple = "35"; cyan = "36"; white = "37"; # Partially from: # https://github.com/ogham/exa/blob/fc6a6d0b38bcf4849e67955d4b60d5d786fceba1/src/info/filetype.rs#L17 immediate_files = [ # Bash expects file types in LS_COLORS to start with "*", so we add # them, despite adding false positives "*readme*" "*Readme*" "*README*" # Bash and zsh doesn't support globs except the starting one "*README.md" "*README.rst" "*.ninja" "*BUILD" "*BUILD.bazel" "*Brewfile" "*CMakeLists.txt" "*Cargo.toml" "*Containerfile" "*Dockerfile" "*Gemfile" "*Gruntfile.coffee" "*Gruntfile.js" "*Justfile" "*Makefile" "*PKGBUILD" "*Pipfile" "*Podfile" "*Procfile" "*Rakefile" "*RoboFile.php" "*SConstruct" "*Vagrantfile" "*WORKSPACE" "*bsconfig.json" "*build.gradle" "*build.sbt" "*build.xml" "*composer.json" "*meson.build" "*mix.exs" "*package.json" "*pom.xml" "*tsconfig.json" "*webpack.config.js" ]; immediate_style = "${bold};${underline};${yellow}"; image_files = [ "*.arw" "*.avif" "*.bmp" "*.cbr" "*.cbz" "*.cr2" "*.dvi" "*.eps" "*.gif" "*.heif" "*.ico" "*.j2c" "*.j2k" "*.jfi" "*.jfif" "*.jif" "*.jp2" "*.jpe" "*.jpeg" "*.jpf" "*.jpg" "*.jpx" "*.jxl" "*.nef" "*.orf" "*.pbm" "*.pgm" "*.png" "*.pnm" "*.ppm" "*.ps" "*.raw" "*.stl" "*.svg" "*.tif" "*.tiff" "*.webp" "*.xpm" ]; image_style = "${purple}"; video_files = [ "*.avi" "*.flv" "*.heic" "*.m2ts" "*.m2v" "*.m4v" "*.mkv" "*.mov" "*.mp4" "*.mpeg" "*.mpg" "*.ogm" "*.ogv" "*.vob" "*.webm" "*.wmv" ]; video_style = "${purple}"; audio_files = [ "*.aac" "*.alac" "*.ape" "*.flac" "*.m4a" "*.mka" "*.mp3" "*.ogg" "*.opus" "*.wav" "*.wma" ]; audio_style = "${cyan}"; crypto_files = [ "*.asc" "*.enc" "*.gpg" "*.p12" "*.pfx" "*.pgp" "*.sig" "*.signature" ]; crypto_style = "${bold};${cyan}"; document_files = [ "*.djvu" "*.doc" "*.docx" "*.dvi" "*.eml" "*.eps" "*.fotd" "*.key" "*.keynote" "*.numbers" "*.odp" "*.odt" "*.pages" "*.pdf" "*.ppt" "*.pptx" "*.rtf" "*.xls" "*.xlsx" ]; document_style = "${yellow}"; compressed_files = [ "*.7z" "*.Z" "*.a" "*.ace" "*.alz" "*.ar" "*.arc" "*.arj" "*.bz" "*.bz2" "*.cab" "*.cpio" "*.deb" "*.dwm" "*.dz" "*.ear" "*.esd" "*.gz" "*.iso" "*.jar" "*.lha" "*.lrz" "*.lz" "*.lz4" "*.lzh" "*.lzma" "*.lzo" "*.rar" "*.rpm" "*.rz" "*.sar" "*.swm" "*.t7z" "*.tar" "*.taz" "*.tbz" "*.tbz2" "*.tgz" "*.tlz" "*.txz" "*.tz" "*.tzo" "*.tzst" "*.war" "*.wim" "*.xz" "*.z" "*.zip" "*.zoo" "*.zst" ]; compressed_style = "${red}"; temp_files = [ "*#" "*~" "*.bak" "*.bk" "*.bkp" "*.dpkg-dist" "*.dpkg-old" "*.old" "*.orig" "*.part" "*.rej" "*.rpmnew" "*.rpmorig" "*.rpmsave" "*.swn" "*.swo" "*.swp" "*.tmp" "*.ucf-dist" "*.ucf-new" "*.ucf-old" ]; # Gray temp_style = "38;5;244"; compiled_files = [ "*.class" "*.elc" "*.hi" "*.ko" "*.o" "*.pyc" "*.zwc" ]; # Gray compiled_style = "38;5;137"; style = files: style: lib.genAttrs files (_: style); colors = ls_colors ({ # directory di = "${bold};${blue}"; # executable ex = "${bold};${green}"; # pipe pi = "${yellow}"; # block device bd = "${bold};${yellow}"; # character device cd = "${bold};${yellow}"; so = "${bold};${purple}"; } // (style immediate_files immediate_style) // (style image_files image_style) // (style video_files video_style) // (style audio_files audio_style) // (style crypto_files crypto_style) // (style document_files document_style) // (style compressed_files compressed_style) // (style temp_files temp_style) // (style compiled_files compiled_style)); in "rs=0:${colors}"; }; home-manager.users.root = {...}: { programs.dircolors = lib.mkDefault config.home-manager.users.minijackson.programs.dircolors; }; }