summaryrefslogtreecommitdiffstats
path: root/common/commandline
diff options
context:
space:
mode:
Diffstat (limited to 'common/commandline')
-rw-r--r--common/commandline/dircolors.nix390
1 files changed, 319 insertions, 71 deletions
diff --git a/common/commandline/dircolors.nix b/common/commandline/dircolors.nix
index f7bdae1..3d27f73 100644
--- a/common/commandline/dircolors.nix
+++ b/common/commandline/dircolors.nix
@@ -1,76 +1,324 @@
1inputs: 1inputs: {
2 2 config,
3{ config, lib, ... }: 3 lib,
4 4 ...
5{ 5}: {
6 home-manager.users.minijackson = { ... }: 6 programs.bash.enableLsColors = false;
7 { 7
8 programs.dircolors = { 8 home-manager.users.minijackson = {config, ...}: {
9 enable = true; 9 # Due to GRML calling dircolors, despite the fact that LS_COLORS is already
10 settings = { 10 # defined
11 # Enable on the alacritty terminal 11 programs.zsh.initExtra = ''
12 TERM = "alacritty*"; 12 ${lib.toShellVar "LS_COLORS" config.home.sessionVariables.LS_COLORS}
13 13 zstyle ':completion:*:default' list-colors ''${(s.:.)LS_COLORS}
14 DIR = "01;94"; 14 '';
15 EXEC = "01;92"; 15
16 16 # TODO: this is not really compatible with 'ls', and hence not compatible
17 FIFO = "93"; # pipe" 17 # with other tools e.g. bash
18 BLK = "93;01"; # block device driver" 18 home.sessionVariables.LS_COLORS = let
19 CHR = "93;01"; # character device driver" 19 ls_colors = set:
20 20 lib.concatStringsSep ":"
21 # archives or compressed (yellow) 21 (lib.mapAttrsToList
22 ".tar" = "01;33"; 22 (key: value: "${key}=${value}")
23 ".tgz" = "01;33"; 23 set);
24 ".arc" = "01;33"; 24
25 ".arj" = "01;33"; 25 bold = "01";
26 ".taz" = "01;33"; 26 underline = "04";
27 ".lha" = "01;33"; 27
28 ".lz4" = "01;33"; 28 red = "31";
29 ".lzh" = "01;33"; 29 green = "32";
30 ".lzma" = "01;33"; 30 yellow = "33";
31 ".tlz" = "01;33"; 31 blue = "34";
32 ".txz" = "01;33"; 32 purple = "35";
33 ".tzo" = "01;33"; 33 cyan = "36";
34 ".t7z" = "01;33"; 34 white = "37";
35 ".zip" = "01;33"; 35
36 ".z" = "01;33"; 36 # Partially from:
37 ".dz" = "01;33"; 37 # https://github.com/ogham/exa/blob/fc6a6d0b38bcf4849e67955d4b60d5d786fceba1/src/info/filetype.rs#L17
38 ".gz" = "01;33"; 38
39 ".lrz" = "01;33"; 39 immediate_files = [
40 ".lz" = "01;33"; 40 # Bash expects file types in LS_COLORS to start with "*", so we add
41 ".lzo" = "01;33"; 41 # them, despite adding false positives
42 ".xz" = "01;33"; 42
43 ".zst" = "01;33"; 43 "*readme*"
44 ".tzst" = "01;33"; 44 "*Readme*"
45 ".bz2" = "01;33"; 45 "*README*"
46 ".bz" = "01;33"; 46
47 ".tbz" = "01;33"; 47 # Bash and zsh doesn't support globs except the starting one
48 ".tbz2" = "01;33"; 48 "*README.md"
49 ".tz" = "01;33"; 49 "*README.rst"
50 ".deb" = "01;33"; 50
51 ".rpm" = "01;33"; 51 "*.ninja"
52 ".jar" = "01;33"; 52
53 ".war" = "01;33"; 53 "*BUILD"
54 ".ear" = "01;33"; 54 "*BUILD.bazel"
55 ".sar" = "01;33"; 55 "*Brewfile"
56 ".rar" = "01;33"; 56 "*CMakeLists.txt"
57 ".alz" = "01;33"; 57 "*Cargo.toml"
58 ".ace" = "01;33"; 58 "*Containerfile"
59 ".zoo" = "01;33"; 59 "*Dockerfile"
60 ".cpio" = "01;33"; 60 "*Gemfile"
61 ".7z" = "01;33"; 61 "*Gruntfile.coffee"
62 ".rz" = "01;33"; 62 "*Gruntfile.js"
63 ".cab" = "01;33"; 63 "*Justfile"
64 ".wim" = "01;33"; 64 "*Makefile"
65 ".swm" = "01;33"; 65 "*PKGBUILD"
66 ".dwm" = "01;33"; 66 "*Pipfile"
67 ".esd" = "01;33"; 67 "*Podfile"
68 }; 68 "*Procfile"
69 }; 69 "*Rakefile"
70 "*RoboFile.php"
71 "*SConstruct"
72 "*Vagrantfile"
73 "*WORKSPACE"
74 "*bsconfig.json"
75 "*build.gradle"
76 "*build.sbt"
77 "*build.xml"
78 "*composer.json"
79 "*meson.build"
80 "*mix.exs"
81 "*package.json"
82 "*pom.xml"
83 "*tsconfig.json"
84 "*webpack.config.js"
85 ];
86 immediate_style = "${bold};${underline};${yellow}";
87
88 image_files = [
89 "*.arw"
90 "*.avif"
91 "*.bmp"
92 "*.cbr"
93 "*.cbz"
94 "*.cr2"
95 "*.dvi"
96 "*.eps"
97 "*.gif"
98 "*.heif"
99 "*.ico"
100 "*.j2c"
101 "*.j2k"
102 "*.jfi"
103 "*.jfif"
104 "*.jif"
105 "*.jp2"
106 "*.jpe"
107 "*.jpeg"
108 "*.jpf"
109 "*.jpg"
110 "*.jpx"
111 "*.jxl"
112 "*.nef"
113 "*.orf"
114 "*.pbm"
115 "*.pgm"
116 "*.png"
117 "*.pnm"
118 "*.ppm"
119 "*.ps"
120 "*.raw"
121 "*.stl"
122 "*.svg"
123 "*.tif"
124 "*.tiff"
125 "*.webp"
126 "*.xpm"
127 ];
128 image_style = "${purple}";
129
130 video_files = [
131 "*.avi"
132 "*.flv"
133 "*.heic"
134 "*.m2ts"
135 "*.m2v"
136 "*.m4v"
137 "*.mkv"
138 "*.mov"
139 "*.mp4"
140 "*.mpeg"
141 "*.mpg"
142 "*.ogm"
143 "*.ogv"
144 "*.vob"
145 "*.webm"
146 "*.wmv"
147 ];
148 video_style = "${purple}";
149
150 audio_files = [
151 "*.aac"
152 "*.alac"
153 "*.ape"
154 "*.flac"
155 "*.m4a"
156 "*.mka"
157 "*.mp3"
158 "*.ogg"
159 "*.opus"
160 "*.wav"
161 "*.wma"
162 ];
163 audio_style = "${cyan}";
164
165 crypto_files = [
166 "*.asc"
167 "*.enc"
168 "*.gpg"
169 "*.p12"
170 "*.pfx"
171 "*.pgp"
172 "*.sig"
173 "*.signature"
174 ];
175 crypto_style = "${bold};${cyan}";
176
177 document_files = [
178 "*.djvu"
179 "*.doc"
180 "*.docx"
181 "*.dvi"
182 "*.eml"
183 "*.eps"
184 "*.fotd"
185 "*.key"
186 "*.keynote"
187 "*.numbers"
188 "*.odp"
189 "*.odt"
190 "*.pages"
191 "*.pdf"
192 "*.ppt"
193 "*.pptx"
194 "*.rtf"
195 "*.xls"
196 "*.xlsx"
197 ];
198 document_style = "${yellow}";
199
200 compressed_files = [
201 "*.7z"
202 "*.Z"
203 "*.a"
204 "*.ace"
205 "*.alz"
206 "*.ar"
207 "*.arc"
208 "*.arj"
209 "*.bz"
210 "*.bz2"
211 "*.cab"
212 "*.cpio"
213 "*.deb"
214 "*.dwm"
215 "*.dz"
216 "*.ear"
217 "*.esd"
218 "*.gz"
219 "*.iso"
220 "*.jar"
221 "*.lha"
222 "*.lrz"
223 "*.lz"
224 "*.lz4"
225 "*.lzh"
226 "*.lzma"
227 "*.lzo"
228 "*.rar"
229 "*.rpm"
230 "*.rz"
231 "*.sar"
232 "*.swm"
233 "*.t7z"
234 "*.tar"
235 "*.taz"
236 "*.tbz"
237 "*.tbz2"
238 "*.tgz"
239 "*.tlz"
240 "*.txz"
241 "*.tz"
242 "*.tzo"
243 "*.tzst"
244 "*.war"
245 "*.wim"
246 "*.xz"
247 "*.z"
248 "*.zip"
249 "*.zoo"
250 "*.zst"
251 ];
252 compressed_style = "${red}";
253
254 temp_files = [
255 "*#"
256 "*~"
257 "*.bak"
258 "*.bk"
259 "*.bkp"
260 "*.dpkg-dist"
261 "*.dpkg-old"
262 "*.old"
263 "*.orig"
264 "*.part"
265 "*.rej"
266 "*.rpmnew"
267 "*.rpmorig"
268 "*.rpmsave"
269 "*.swn"
270 "*.swo"
271 "*.swp"
272 "*.tmp"
273 "*.ucf-dist"
274 "*.ucf-new"
275 "*.ucf-old"
276 ];
277 # Gray
278 temp_style = "38;5;244";
279
280 compiled_files = [
281 "*.class"
282 "*.elc"
283 "*.hi"
284 "*.ko"
285 "*.o"
286 "*.pyc"
287 "*.zwc"
288 ];
289 # Gray
290 compiled_style = "38;5;137";
291
292 style = files: style: lib.genAttrs files (_: style);
293
294 colors = ls_colors ({
295 # directory
296 di = "${bold};${blue}";
297 # executable
298 ex = "${bold};${green}";
299
300 # pipe
301 pi = "${yellow}";
302 # block device
303 bd = "${bold};${yellow}";
304 # character device
305 cd = "${bold};${yellow}";
306
307 so = "${bold};${purple}";
308 }
309 // (style immediate_files immediate_style)
310 // (style image_files image_style)
311 // (style video_files video_style)
312 // (style audio_files audio_style)
313 // (style crypto_files crypto_style)
314 // (style document_files document_style)
315 // (style compressed_files compressed_style)
316 // (style temp_files temp_style)
317 // (style compiled_files compiled_style));
318 in "rs=0:${colors}";
70 }; 319 };
71 320
72 home-manager.users.root = { ... }: 321 home-manager.users.root = {...}: {
73 {
74 programs.dircolors = 322 programs.dircolors =
75 lib.mkDefault config.home-manager.users.minijackson.programs.dircolors; 323 lib.mkDefault config.home-manager.users.minijackson.programs.dircolors;
76 }; 324 };