repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

adds readme

4659d3d563aa80f085602fba5e28ace0694e4034

Oliver Krylow <o.krylow@isp-insoft.de> ·

unsigned

Browse filesCompare with HEAD

cleanup tools. killing babies.
improve neovim theme.

Changed files (20)

README.md

Modified
1 1 # bugabingas personal dotfiles, 33rd attempt
3 +Shared configuration files between some Linux and some Windows hosts.
3 5 ## bootstrapping a new host
7 +1. Install git
8 +1. Install a JDK
9 +1. git clone git@github.com:bugabinga/dotfiles
10 +1. `cd dotfiles`
11 +1. `java bootstripper.java .`
13 +> Pay attention to already existing symlinks!
15 +## rough goals
17 +- minimal amount of dependencies
18 + This helps in setting up new host.
19 + But it is really hard to achieve when hosts are allowed to be Windows and Linux AND [OpenBSD] ...
20 + The current state is a compromise reached after some experimentation.
21 +- editing and applying configs is "natural"
22 + Natural in this context is to mean: as if there was no dotfiles repository used for sharing.
23 + This is achieved by symlinking the files from the dotfiles repository into their normal locations.
24 + So when it comes time to edit a confg file, you can stay blissfully unaware of the dotfiles repository.
5 26 ## handling per host differences
7 -## Secrets
28 +There are two classes of differences in configurations between platforms (specifically Linux and Windows in my case).
30 +### differing locations of config files
32 +For example, [NeoVim] stores its configuration at `~/.config/nvim` in Linux and at `~/AppData/Roaming/nvim` in Windows.
33 +In order to handle theses differences each host gets its own symlink file wiht the naming pattern `(hostname).symlinks`.
34 +The format of this file is:
35 +```
36 +path to configuration file/directory relative to dotfiles root
37 +absolute path of symlink on host
38 +```
39 +Each symlink path pair is to be delimited by a newline.
40 +Example:
41 +```
42 +neovim
43 +~/.config/nvim
45 +foo/bar.conf
46 +~/.config/foobar.conf
47 +```
48 +This file will be parsed by [bootstripper] in order to create those symlinks.
50 +### differing values in configration files
52 +Most often, these come down to different paths of stuff, that get refered to in config files.
53 +For example, [topgrade], an abstraction over a bunch of package managers and updaters, might want to know the location of your git repositories, so it can pull them for you.
54 +Some programs, e.g. [NeoVim], have rich configuration languages that are powerful enough for you to resolve those differences with conditionals.
55 +However some programs, e.g. [topgrade], offer only declarative configuration languages, which make it impossible to resolve this problem in the config.
56 +I tried solving this problem with some kind of a templating engine.
57 +But I quickly gave up on that, because it was too annoying to manage.
58 +Specifically, editing configuration stopped being "natural", meaning you cannot simply open and edit the file at the location you expect the config to be anymore.
59 +This natural flow is the reason symlinks are used.
60 +With templating in the mix, an intermediary step is necessary, between editing and applying config.
61 +Too much work.
62 +Instead, I use the `(hostname).symlink` files to resolve such cases.
63 +That means, that config files are completely independent per host, and as such some duplication of configuration occurs.
64 +A tradeoff well worth it in my opinion.
66 +## secrets
68 +Secrets are encrypted and saved as file into the `tresor` folder.
69 +The name of these file is a random UUID, which I map to their original purpose somewhere else.
70 +Those secret files are decrypted either by [bootstripper] or on demand in my scripts.
72 +## the trouble with bootstrapping dotfiles
74 +Most of my previous attempts at managing my configuration files failed because it is tricky to share them between Windows and Unix systems.
75 +If all my hosts were Unix(y), I would write a POSIX shell script and be done with it.
76 +But that does not work for Windows.
78 +Since I find it important to be able to setup my configuration files on any fresh new host, it is important to have as few dependencies as possible.
79 +However, with Windows in the mix, this is pretty hard, so I settled on a compromise: JDK.
81 +Things I tried in the past to solve this problem:
83 +- dotfiles managers (e.g. [chezmoi])
84 + > too much work
85 +- writing a bootstrap/installer with [cosmopolitan]
86 + > extremely cool tech. unfortunatelly I am not a C programmer so I struggled a lot.
87 + > also, the resulting binary rewrites itself on first run. How do I keep a file version controlled that is allowed to change on first use, but should not result in a new modification...?
88 + > furthermore, managing the [cosmopolitan] toolchain for windows made extra work.
89 +- use POSIX shell for Unix, use PowerShell for Windows
90 + > too much work. maintaining the same program in 2 different languages ... depressing not because you have to write twice, but because you have to test twice.
91 +- Pretend Windows is Unix by only interfacing with it through [WSL].
92 + > Windows is not Unix. [WSL] is cute, even useful for cross-compilation and testing. But when I am on Windows I want to use Windows, when I am on Linux I want to use Linux. Fighting the platform constantly is too tiring.
94 +Things I have not tried (yet?):
96 +- Use a language with a pleasant cross-compile story ([golang], [Rust], [ziglang]) and version control a binary for those platforms I care about.
97 +- Use [PowerShell Core] and maybe a script per platform to install it. This could be nice if [PowerShell Core] would replace [PowerShell Windows] and it was my main shell.
99 +[NeoVim]: https://neovim.io/
100 +[topgrade]: https://github.com/r-darwish/topgrade
101 +[bootstripper]: https://github.com/bugabinga/dotfiles/blob/trunk/bootstripper.java
102 +[chezmoi]: https://github.com/twpayne/chezmoi
103 +[golang]: https://golang.org/
104 +[Rust]: https://www.rust-lang.org/
105 +[ziglang]: https://ziglang.org/
106 +[WSL]: https://docs.microsoft.com/en-us/windows/wsl/about
107 +[PowerShell Core]: https://github.com/PowerShell/PowerShell
108 +[PowerShell Windows]: https://de.wikipedia.org/wiki/PowerShell
109 +[OpenBSD]: https://www.openbsd.org/

TODO.md

Modified
28 28 - bandwhich: show network traffic information
29 29 - so: search Stack Exchange
30 30 - prose: simple text (markdown, emails, paragraphs) formatter
31 +- linky: check markdown for broken links
32 +- comrak: render markdown to html
32 34 ## Stuff to do
34 -- [ ] kill thy babbies: remove obsolete java commands. nu has builtins now for checksums and for random uuids
35 36 - [ ] rewrite bootstripper and java commmands with zig. how to run them? precompile? zig run?
36 37 - [ ] encrypt box key
37 -- [ ] use [systemd user] instance to manage env vars
38 -- [ ] how to abstract configs differences per platform? templates are painful to work with.
39 - - [ ] abstract indexa config for windows / linux
41 39 ## Done
41 +- [x] how to abstract configs differences per platform? templates are painful to work with.
42 +- [x] abstract indexa config for windows / linux
43 +- [x] kill thy babbies: remove obsolete java commands. nu has builtins now for checksums and for random uuids
44 +- [x] use [systemd user] instance to manage env vars
43 45 - [x] what to do about ssh and GPG keys? or secrets in general?
44 46 - [x] say goodbye to GPG, too hard to manage.
45 47 - [x] how to handle java tools in `tools` cross platform?

bootstripper.java

Modified
42 42 var is_directory = Files.isDirectory(source_path);
43 43 if(Files.exists(target_path, LinkOption.NOFOLLOW_LINKS)){
44 44 if(Files.exists(target_path)) {
45 - System.out.printf("✅ %s already exists!%nNot linking %s.%n", emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
45 + System.out.printf("%n✅ %s already exists!%nNot linking %s.%n", emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
46 46 return;
48 48 else {

neovim/init.lua

Modified
23 23 -- import `dump` into the global namespace, so that we can use it in a running vim instance: `:lua dump(vim.fn)`
24 24 _G.dump = require("dump")
25 --- import `syntax_stack` into global namespace. shows the highlight group under cursor
26 -_G.syntax_stack = require("syntax_stack")
27 25 -- Define some standard path locations where we will put stuff into.
28 26 -- `data` is for persistent data like logs, backups and file states.
29 27 -- `config` is for configuration code itself and plugins.
57 55 local _, setup_mkdir = require("mkdir")()
58 56 setup_mkdir(autocommand)
60 --- Commands have no nvim API yet, so we use vimscript...
61 -cheatsheet(":WhatHighlight => This command shows the highlight group under the cursor")
62 -vim.cmd([[command! WhatHighlight lua syntax_stack()]])
63 58 cheatsheet(
64 59 ":TSHighlightCapturesUnderCursor => This command shows the highlight group under the cursor, when TreeSitter is used"

neovim/lua/keybinds.lua

Modified
14 14 -- Let the <LEADER> key be <SPACE>
15 15 vim.g.mapleader = " "
17 - map("n", "<LEADER><F12>", [[<CMD>lua require('glow').glow('<f-args>')<CR>]])
18 - cheatsheet("LEADER + F12 => Render Markdown Preview")
20 17 map("n", "<LEADER><F9>", [[<CMD>tabnew $MYVIMRC<CR>]])
21 18 cheatsheet("LEADER + F9 => Open nvim configuration in a new tab!")
30 27 -- Clear highlighted search results whenever ESC is hit
31 28 map("n", "<ESC>", ":nohlsearch<CR>", { unique = false, silent = true })
30 + map("n", "<LEADER>t", [[<CMD>Telescope tabs<CR>]])
31 + cheatsheet("LEADER + t => Select a tab")
33 33 map("n", "<LEADER>b", [[<CMD>Telescope buffers<CR>]])
34 34 cheatsheet("LEADER + b => Select a buffer")
35 36 map("n", "<LEADER>f", [[<CMD>Telescope file_browser<CR>]])
36 37 cheatsheet("LEADER + f => Select a file")
37 39 map("n", "<LEADER>e", [[<CMD>NvimTreeToggle<CR>]])
38 40 cheatsheet("LEADER + e => Toggle file explorer")
52 54 map("n", "gx", [[<CMD>lua require'spawn'(']] .. opener_program .. [[',{ vim.fn.expand('<cfile>') } )<CR>]])
53 55 cheatsheet("gx => Open URL under cursor")
57 + cheatsheet("<ALT>j => Move line(s) down")
58 + cheatsheet("<ALT>k => Move line(s) up")
59 + map("n", "<A-j>", [[<CMD>move .+1<CR>==]])
60 + map("n", "<A-k>", [[<CMD>move .-2<CR>==]])
61 + map("i", "<A-j>", [[<ESC><CMD>move .+1<CR>==gi]])
62 + map("i", "<A-k>", [[<ESC><CMD>move .-2<CR>==gi]])
63 + map("x", "<A-j>", [[<ESC><CMD>'<,'>move'>+1<CR>gv=gv]])
64 + map("x", "<A-k>", [[<ESC><CMD>'<,'>move'<-2<CR>gv=gv]])

neovim/lua/plugins.lua

Modified
112 112 require("nvim-treesitter.configs").setup({
113 113 ensure_installed = { "zig", "java", "rust", "lua", "toml", "yaml", "json", "c" },
114 114 highlight = { enable = true },
115 - incremental_selection = { enable = true },
115 + incremental_selection = {
116 + enable = true,
117 + keymaps = {
118 + init_selection = "<C-Up>",
119 + node_incremental = "<C-Up>",
120 + node_decremental = "<C-Down>",
121 + scope_incremental = "<A-Up>",
122 + },
123 + },
116 124 indent = { enable = true },
117 125 query_linter = { enable = true, use_virtual_text = true, lint_events = { "BufWrite" } },

neovim/lua/syntax_stack.lua

Deleted
deleted file mode 100644
1 --- Prints the highlight group name of the syntax element under the cursor.
2 -return function()
3 - local syntax_id = vim.fn.synID(vim.fn.line '.', vim.fn.col '.', 1)
4 - print(
5 - vim.fn.synIDattr(syntax_id, 'name')
6 - .. ' -> '
7 - .. vim.fn.synIDattr(vim.fn.synIDtrans(syntax_id), 'name')
8 - )
9 -end

neovim/lua/theme/diff_colors.lua

Deleted
deleted file mode 100644
1 -return function(Group, groups, colors, styles)
2 - Group.new('DiffAdd', colors.normal, colors.none, styles.NONE)
3 - Group.new('DiffChange', colors.normal, colors.none, styles.NONE)
4 - Group.new('DiffDelete', colors.normal, colors.none, styles.NONE)
5 - Group.new('DiffText', colors.normal, colors.none, styles.NONE)
6 -end

neovim/lua/theme/init.lua

Modified
22 22 --intentionally ugly and easy to spot color, so that i can find out where it is used
23 23 Color.new("debug", "#f111e1")
25 - require("theme.terminal_colors")(Group, groups, colors, styles)
25 + -- TERMINAL COLORS
26 + vim.g.terminal_color_0 = "#555555"
27 + vim.g.terminal_color_1 = "#FB467B"
28 + vim.g.terminal_color_2 = "#B8EE92"
29 + vim.g.terminal_color_3 = "#FFCC00"
30 + vim.g.terminal_color_4 = "#56D6D6"
31 + vim.g.terminal_color_5 = "#B954B8"
32 + vim.g.terminal_color_6 = "#00D5A7"
33 + vim.g.terminal_color_7 = "#CED5E5"
34 + vim.g.terminal_color_8 = "5555555"
35 + vim.g.terminal_color_9 = "#FB467B"
36 + vim.g.terminal_color_10 = "#B8EE92"
37 + vim.g.terminal_color_11 = "#FFCC00"
38 + vim.g.terminal_color_12 = "#56D6D6"
39 + vim.g.terminal_color_13 = "#B954B8"
40 + vim.g.terminal_color_14 = "#00D5A7"
41 + vim.g.terminal_color_15 = "#CED5E5"
26 43 require("theme.nvim_editor_colors")(Group, groups, colors, styles)
27 44 require("theme.lsp_colors")(Group, groups, colors, styles)
28 45 require("theme.treesitter_colors")(Group, groups, colors, styles)
29 - require("theme.java_colors")(Group, groups, colors, styles)
30 - require("theme.lua_colors")(Group, groups, colors, styles)
31 - require("theme.nvim_tree_colors")(Group, groups, colors, styles)
32 - require("theme.diff_colors")(Group, groups, colors, styles)

neovim/lua/theme/java_colors.lua

Deleted
deleted file mode 100644
1 -return function(Group, _groups, colors, styles)
2 - Group.new('javaOperator', colors.normal, colors.none, styles.NONE)
3 - Group.new('javaVarArg', colors.normal, colors.none, styles.NONE)
4 - Group.new('javaParen', colors.normal, colors.none, styles.NONE)
5 - Group.new('javaParen1', colors.normal, colors.none, styles.NONE)
6 - Group.new('javaParen2', colors.normal, colors.none, styles.NONE)
7 - Group.new('javaParen3', colors.normal, colors.none, styles.NONE)
8 - Group.new('javaParen4', colors.normal, colors.none, styles.NONE)
9 - Group.new('javaParen5', colors.normal, colors.none, styles.NONE)
10 - Group.new('javaAnnotation', colors.normal, colors.none, styles.NONE)
11 - Group.new('javaDocTags', colors.normal, colors.none, styles.NONE)
12 - Group.new(
13 - 'javaCommentTitle',
14 - colors.important,
15 - colors.none,
16 - styles.bold + styles.underline
17 - )
18 -end

neovim/lua/theme/lsp_colors.lua

Modified
1 1 return function(Group, groups, colors, styles)
2 - Group.new(
3 - 'LspDiagnosticsVirtualTextHint',
4 - colors.normal,
5 - colors.none,
6 - styles.NONE
7 - )
8 - Group.new(
9 - 'LspDiagnosticsSignWarning',
10 - colors.normal,
11 - colors.none,
12 - styles.NONE
13 - )
14 - Group.new(
15 - 'LspDiagnosticsSignInformation',
16 - colors.normal,
17 - colors.none,
18 - styles.NONE
19 - )
20 - Group.new('LspDiagnosticsSignHint', colors.normal, colors.none, styles.NONE)
21 - Group.new(
22 - 'LspDiagnosticsFloatingHint',
23 - colors.normal,
24 - colors.none,
25 - styles.underline
26 - )
27 - Group.new('LspDiagnosticsSignError', colors.normal, colors.none, styles.NONE)
28 - Group.new(
29 - 'LspDiagnosticsDefaultWarning',
30 - colors.normal,
31 - colors.none,
32 - styles.NONE
33 - )
34 - Group.new(
35 - 'LspDiagnosticsDefaultError',
36 - colors.normal,
37 - colors.none,
38 - styles.NONE
39 - )
40 - Group.new(
41 - 'LspDiagnosticsFloatingError',
42 - colors.normal,
43 - colors.none,
44 - styles.underline
45 - )
46 - Group.new(
47 - 'LspDiagnosticsFloatingWarning',
48 - colors.normal,
49 - colors.none,
50 - styles.underline
51 - )
52 - Group.new(
53 - 'LspDiagnosticsFloatingInformation',
54 - colors.normal,
55 - colors.none,
56 - styles.underline
57 - )
58 - Group.new(
59 - 'LspDiagnosticsUnderlineInformation',
60 - colors.normal,
61 - colors.none,
62 - styles.underline
63 - )
64 - Group.new(
65 - 'LspDiagnosticsUnderlineHint',
66 - colors.normal,
67 - colors.none,
68 - styles.underline
69 - )
70 - Group.new(
71 - 'LspDiagnosticsDefaultInformation',
72 - colors.normal,
73 - colors.none,
74 - styles.NONE
75 - )
76 - Group.new(
77 - 'LspDiagnosticsDefaultHint',
78 - colors.normal,
79 - colors.none,
80 - styles.NONE
81 - )
82 - Group.new(
83 - 'LspDiagnosticsUnderlineError',
84 - colors.normal,
85 - colors.none,
86 - styles.underline
87 - )
88 - Group.new(
89 - 'LspDiagnosticsVirtualTextError',
90 - colors.normal,
91 - colors.none,
92 - styles.NONE
93 - )
94 - Group.new(
95 - 'LspDiagnosticsVirtualTextWarning',
96 - colors.normal,
97 - colors.none,
98 - styles.NONE
99 - )
100 - Group.new(
101 - 'LspDiagnosticsVirtualTextInformation',
102 - colors.normal,
103 - colors.none,
104 - styles.NONE
105 - )
106 - Group.new(
107 - 'LspDiagnosticsUnderlineWarning',
108 - colors.normal,
109 - colors.none,
110 - styles.underline
111 - )
2 + Group.new("LspDiagnosticsVirtualTextHint", colors.normal, colors.none, styles.NONE)
3 + Group.new("LspDiagnosticsSignWarning", colors.warning, colors.none, styles.NONE)
4 + Group.new("LspDiagnosticsSignInformation", colors.normal, colors.none, styles.NONE)
5 + Group.new("LspDiagnosticsSignHint", colors.normal, colors.none, styles.NONE)
6 + Group.new("LspDiagnosticsFloatingHint", colors.normal, colors.none, styles.underline)
7 + Group.new("LspDiagnosticsSignError", colors.error, colors.none, styles.NONE)
8 + Group.new("LspDiagnosticsDefaultWarning", colors.warning, colors.none, styles.NONE)
9 + Group.new("LspDiagnosticsDefaultError", colors.error, colors.none, styles.NONE)
10 + Group.new("LspDiagnosticsFloatingError", colors.error, colors.none, styles.underline)
11 + Group.new("LspDiagnosticsFloatingWarning", colors.warning, colors.none, styles.underline)
12 + Group.new("LspDiagnosticsFloatingInformation", colors.normal, colors.none, styles.underline)
13 + Group.new("LspDiagnosticsUnderlineInformation", colors.normal, colors.none, styles.underline)
14 + Group.new("LspDiagnosticsUnderlineHint", colors.normal, colors.none, styles.underline)
15 + Group.new("LspDiagnosticsDefaultInformation", colors.normal, colors.none, styles.NONE)
16 + Group.new("LspDiagnosticsDefaultHint", colors.normal, colors.none, styles.NONE)
17 + Group.new("LspDiagnosticsUnderlineError", colors.error, colors.none, styles.underline)
18 + Group.new("LspDiagnosticsVirtualTextError", colors.error, colors.none, styles.NONE)
19 + Group.new("LspDiagnosticsVirtualTextWarning", colors.normal, colors.none, styles.NONE)
20 + Group.new("LspDiagnosticsVirtualTextInformation", colors.normal, colors.none, styles.NONE)
21 + Group.new("LspDiagnosticsUnderlineWarning", colors.normal, colors.none, styles.underline)

neovim/lua/theme/lua_colors.lua

Deleted
deleted file mode 100644
1 -return function(Group, groups, colors, styles)
2 - Group.new('luaFunction', colors.normal, colors.none, styles.NONE)
3 - Group.new('luaTable', colors.normal, colors.none, styles.NONE)
4 - Group.new('luaIn', colors.normal, colors.none, styles.NONE)
5 - Group.new('luastatement', colors.normal, colors.none, styles.NONE)
6 -end

neovim/lua/theme/nvim_editor_colors.lua

Modified
1 1 return function(Group, groups, colors, styles)
2 - -- SYNTAX
3 - Group.new('Normal', colors.normal, colors.none, styles.NONE)
4 - Group.new('NormalNC', colors.minor, colors.none, styles.NONE)
5 - Group.new('NormalFloat', colors.important, colors.none, styles.NONE)
2 + -- SYNTAX
3 + Group.new("Normal", colors.normal, colors.none, styles.NONE)
4 + Group.new("NormalNC", colors.minor, colors.none, styles.NONE)
5 + Group.new("NormalFloat", colors.important, colors.none, styles.NONE)
7 - Group.new(
8 - 'Comment',
9 - colors.important,
10 - colors.none,
11 - styles.bold + styles.italic
12 - )
7 + Group.new("Comment", colors.important, colors.none, styles.bold + styles.italic)
14 - Group.new('Constant', colors.debug, colors.none, styles.NONE)
15 - Group.new('String', colors.normal, colors.none, styles.bold + styles.italic)
16 - Group.new('Character', groups.String, groups.String, groups.String)
17 - Group.new('Number', groups.String, groups.String, groups.String)
18 - Group.new('Float', groups.String, groups.String, groups.String)
19 - Group.new('Boolean', groups.String, groups.String, groups.String)
9 + Group.new("Constant", colors.normal, colors.none, styles.bold)
10 + Group.new("String", colors.normal, colors.none, styles.bold + styles.italic)
11 + Group.new("Character", groups.String, groups.String, groups.String)
12 + Group.new("Number", groups.String, groups.String, groups.String)
13 + Group.new("Float", groups.String, groups.String, groups.String)
14 + Group.new("Boolean", groups.String, groups.String, groups.String)
21 - Group.new('Identifier', colors.normal, colors.none, styles.none)
22 - Group.new('Function', groups.Identifier, groups.Identifier, groups.Identifier)
16 + Group.new("Identifier", colors.normal, colors.none, styles.none)
17 + Group.new("Function", groups.Identifier, groups.Identifier, groups.Identifier)
24 - Group.new('Statement', colors.minor, colors.none, styles.italic)
25 - Group.new('Conditional', groups.Statement, groups.Statement, groups.Statement)
26 - Group.new('Repeat', groups.Statement, groups.Statement, groups.Statement)
27 - Group.new(
28 - 'Label',
29 - groups.Statement,
30 - groups.Statement,
31 - groups.Statement + styles.underline
32 - )
33 - Group.new('Operator', groups.Statement, groups.Statement, groups.Statement)
34 - Group.new('Keyword', groups.Statement, groups.Statement, groups.Statement)
35 - Group.new('Exception', groups.Statement, groups.Statement, groups.Statement)
19 + Group.new("Statement", colors.minor, colors.none, styles.italic)
20 + Group.new("Conditional", groups.Statement, groups.Statement, groups.Statement)
21 + Group.new("Repeat", groups.Statement, groups.Statement, groups.Statement)
22 + Group.new("Label", groups.Statement, groups.Statement, groups.Statement + styles.underline)
23 + Group.new("Operator", groups.Statement, groups.Statement, groups.Statement)
24 + Group.new("Keyword", groups.Statement, groups.Statement, groups.Statement)
25 + Group.new("Exception", groups.Statement, groups.Statement, groups.Statement)
37 - Group.new('PreProc', groups.Statement, groups.Statement, groups.Statement)
38 - Group.new('Include', groups.PreProc, groups.PreProc, groups.PreProc)
39 - Group.new('Define', groups.PreProc, groups.PreProc, groups.PreProc)
40 - Group.new('Macro', groups.PreProc, groups.PreProc, groups.PreProc)
41 - Group.new('PreCondit', groups.PreProc, groups.PreProc, groups.PreProc)
27 + Group.new("PreProc", groups.Statement, groups.Statement, groups.Statement)
28 + Group.new("Include", groups.PreProc, groups.PreProc, groups.PreProc)
29 + Group.new("Define", groups.PreProc, groups.PreProc, groups.PreProc)
30 + Group.new("Macro", groups.PreProc, groups.PreProc, groups.PreProc)
31 + Group.new("PreCondit", groups.PreProc, groups.PreProc, groups.PreProc)
43 - Group.new('Type', colors.normal, colors.none, styles.bold)
44 - Group.new(
45 - 'StorageClass',
46 - groups.Statement,
47 - groups.Statement,
48 - groups.Statement
49 - )
50 - Group.new('Structure', groups.Statement, groups.Statement, groups.Statement)
51 - Group.new('Typedef', groups.Type, groups.Type, groups.Type)
33 + Group.new("Type", colors.normal, colors.none, styles.bold)
34 + Group.new("StorageClass", groups.Statement, groups.Statement, groups.Statement)
35 + Group.new("Structure", groups.Statement, groups.Statement, groups.Statement)
36 + Group.new("Typedef", groups.Type, groups.Type, groups.Type)
53 - Group.new('Special', colors.minor, colors.none, styles.NONE)
54 - Group.new('SpecialKey', colors.normal, colors.none, styles.italic)
55 - Group.new('SpecialComment', colors.accent_strong, colors.none, styles.bold)
56 - Group.new('Tag', groups.Special, groups.Special, groups.Special)
57 - Group.new('Delimiter', groups.Special, groups.Special, groups.Special)
58 - Group.new('Debug', groups.Special, groups.Special, groups.Special)
38 + Group.new("Special", colors.minor, colors.none, styles.NONE)
39 + Group.new("SpecialKey", colors.normal, colors.none, styles.italic)
40 + Group.new("SpecialComment", colors.accent_strong, colors.none, styles.bold)
41 + Group.new("Tag", groups.Special, groups.Special, groups.Special)
42 + Group.new("Delimiter", groups.Special, groups.Special, groups.Special)
43 + Group.new("Debug", groups.Special, groups.Special, groups.Special)
60 - Group.new('Underlined', colors.accent_strong, colors.none, styles.underline)
61 - Group.new('Ignore', colors.debug, colors.none, styles.NONE)
62 - Group.new('Error', colors.error, colors.none, styles.bold + styles.underline)
63 - Group.new(
64 - 'Todo',
65 - colors.accent_strong,
66 - colors.none,
67 - styles.bold + styles.underline
68 - )
45 + Group.new("Underlined", colors.accent_strong, colors.none, styles.underline)
46 + Group.new("Ignore", colors.debug, colors.none, styles.NONE)
47 + Group.new("Error", colors.error, colors.none, styles.bold + styles.underline)
48 + Group.new("Todo", colors.accent_strong, colors.none, styles.bold + styles.underline)
70 - Group.new('Whitespace', colors.nonessential, colors.none, styles.NONE)
71 - Group.new('NonText', colors.debug, colors.none, styles.NONE)
50 + Group.new("Whitespace", colors.nonessential, colors.none, styles.NONE)
51 + Group.new("NonText", colors.debug, colors.none, styles.NONE)
73 - -- NVIM UI
74 - Group.new(
75 - 'NvimInternalError',
76 - colors.error,
77 - colors.none,
78 - styles.bold + styles.underline
79 - )
80 - Group.new('ErrorMsg', colors.error, colors.none, styles.bold)
81 - Group.new('WarningMsg', colors.warning, colors.none, styles.bold)
82 - Group.new('MoreMsg', colors.information, colors.none, styles.NONE)
83 - Group.new('ModeMsg', colors.information, colors.none, styles.NONE)
84 - Group.new('Question', colors.information, colors.none, styles.bold)
85 - Group.new('MsgSeparator', colors.ui_minor, colors.none, styles.NONE)
86 - Group.new('MsgArea', colors.ui_normal, colors.none, styles.NONE)
53 + -- NVIM UI
54 + Group.new("NvimInternalError", colors.error, colors.none, styles.bold + styles.underline)
55 + Group.new("ErrorMsg", colors.error, colors.none, styles.bold)
56 + Group.new("WarningMsg", colors.warning, colors.none, styles.bold)
57 + Group.new("MoreMsg", colors.information, colors.none, styles.NONE)
58 + Group.new("ModeMsg", colors.information, colors.none, styles.NONE)
59 + Group.new("Question", colors.information, colors.none, styles.bold)
60 + Group.new("MsgSeparator", colors.ui_minor, colors.none, styles.NONE)
61 + Group.new("MsgArea", colors.ui_normal, colors.none, styles.NONE)
88 - Group.new('EndOfBuffer', colors.nonessential, colors.none, styles.NONE)
89 - Group.new('LineNr', colors.nonessential, colors.none, styles.NONE)
90 - Group.new('CursorLineNr', colors.ui_normal, colors.none, styles.NONE)
91 - Group.new('CursorColumn', colors.none, colors.none, styles.inverse)
92 - Group.new('CursorLine', colors.none, colors.accent_weak, styles.NONE)
93 - Group.new('TermCursor', colors.none, colors.none, styles.inverse)
94 - Group.new('TermCursorNC', colors.none, colors.none, styles.NONE)
95 - Group.new('Cursor', colors.none, colors.none, styles.reverse)
96 - Group.new('lCursor', groups.Cursor, groups.Cursor, groups.Cursor)
97 - Group.new('ColorColumn', colors.none, colors.ui_normal, styles.NONE)
98 - Group.new('Visual', colors.accent_strong, colors.none, styles.NONE)
99 - Group.new('VisualNC', colors.accent_weak, colors.none, styles.NONE)
100 - Group.new('Conceal', colors.debug, colors.none, styles.NONE)
101 - Group.new('Substitute', colors.information, colors.none, styles.NONE)
102 - Group.new('MatchParen', colors.accent_strong, colors.none, styles.bold)
63 + Group.new("EndOfBuffer", colors.nonessential, colors.none, styles.NONE)
64 + Group.new("LineNr", colors.nonessential, colors.none, styles.NONE)
65 + Group.new("CursorLineNr", colors.ui_normal, colors.none, styles.NONE)
66 + Group.new("CursorColumn", colors.none, colors.none, styles.inverse)
67 + Group.new("CursorLine", colors.none, colors.accent_weak, styles.NONE)
68 + Group.new("TermCursor", colors.none, colors.none, styles.inverse)
69 + Group.new("TermCursorNC", colors.none, colors.none, styles.NONE)
70 + Group.new("Cursor", colors.none, colors.none, styles.reverse)
71 + Group.new("lCursor", groups.Cursor, groups.Cursor, groups.Cursor)
72 + Group.new("ColorColumn", colors.none, colors.ui_normal, styles.NONE)
73 + Group.new("Visual", colors.accent_strong, colors.none, styles.NONE)
74 + Group.new("VisualNC", colors.accent_weak, colors.none, styles.NONE)
75 + Group.new("Conceal", colors.debug, colors.none, styles.NONE)
76 + Group.new("Substitute", colors.information, colors.none, styles.NONE)
77 + Group.new("MatchParen", colors.accent_strong, colors.none, styles.bold)
104 - Group.new('Directory', colors.normal, colors.none, styles.bold)
105 - Group.new(
106 - 'Title',
107 - colors.ui_normal,
108 - colors.none,
109 - styles.bold + styles.underline
110 - )
79 + Group.new("Directory", colors.normal, colors.none, styles.bold)
80 + Group.new("Title", colors.ui_normal, colors.none, styles.bold + styles.underline)
112 - Group.new('IncSearch', colors.ui_important, colors.none, styles.underline)
113 - Group.new('Search', colors.important, colors.ui_important, styles.NONE)
114 - Group.new('VertSplit', colors.ui_normal, colors.none, styles.NONE)
115 - Group.new('WildMenu', colors.ui_normal, colors.none, styles.NONE)
116 - Group.new('Folded', colors.nonessential, colors.none, styles.NONE)
117 - Group.new('FoldColumn', colors.ui_normal, colors.none, styles.NONE)
118 - Group.new('SignColumn', colors.ui_normal, colors.none, styles.NONE)
119 - Group.new('StatusLine', colors.nonessential, colors.none, styles.NONE)
120 - Group.new('StatusLineNC', colors.none, colors.none, styles.NONE)
121 - Group.new('Pmenu', colors.ui_normal, colors.none, styles.NONE)
122 - Group.new('PmenuSel', colors.ui_important, colors.none, styles.underline)
123 - Group.new('PmenuSbar', colors.ui_minor, colors.none, styles.NONE)
124 - Group.new('PmenuThumb', colors.ui_important, colors.none, styles.NONE)
125 - Group.new('TabLine', colors.ui_normal, colors.none, styles.none)
126 - Group.new(
127 - 'TabLineSel',
128 - colors.ui_important,
129 - colors.none,
130 - styles.bold + styles.underline
131 - )
132 - Group.new('TabLineFill', colors.ui_minor, colors.none, styles.NONE)
133 - Group.new('QuickFixLine', colors.ui_normal, colors.none, styles.NONE)
82 + Group.new("IncSearch", colors.ui_important, colors.none, styles.underline)
83 + Group.new("Search", colors.important, colors.ui_important, styles.NONE)
84 + Group.new("VertSplit", colors.ui_normal, colors.none, styles.NONE)
85 + Group.new("WildMenu", colors.ui_normal, colors.none, styles.NONE)
86 + Group.new("Folded", colors.nonessential, colors.none, styles.NONE)
87 + Group.new("FoldColumn", colors.ui_normal, colors.none, styles.NONE)
88 + Group.new("SignColumn", colors.ui_normal, colors.none, styles.NONE)
89 + Group.new("StatusLine", colors.nonessential, colors.none, styles.NONE)
90 + Group.new("StatusLineNC", colors.none, colors.none, styles.NONE)
91 + Group.new("Pmenu", colors.ui_normal, colors.none, styles.NONE)
92 + Group.new("PmenuSel", colors.ui_important, colors.none, styles.underline)
93 + Group.new("PmenuSbar", colors.ui_minor, colors.none, styles.NONE)
94 + Group.new("PmenuThumb", colors.ui_important, colors.none, styles.NONE)
95 + Group.new("TabLine", colors.ui_normal, colors.none, styles.none)
96 + Group.new("TabLineSel", colors.ui_important, colors.none, styles.bold + styles.underline)
97 + Group.new("TabLineFill", colors.ui_minor, colors.none, styles.NONE)
98 + Group.new("QuickFixLine", colors.ui_normal, colors.none, styles.NONE)
135 - Group.new('SpellBad', colors.warning, colors.none, styles.undercurl)
136 - Group.new('SpellCap', colors.debug, colors.none, styles.NONE)
137 - Group.new('SpellRare', colors.debug, colors.none, styles.NONE)
138 - Group.new('SpellLocal', colors.debug, colors.none, styles.NONE)
100 + Group.new("SpellBad", colors.warning, colors.none, styles.undercurl)
101 + Group.new("SpellCap", colors.debug, colors.none, styles.NONE)
102 + Group.new("SpellRare", colors.debug, colors.none, styles.NONE)
103 + Group.new("SpellLocal", colors.debug, colors.none, styles.NONE)
140 - Group.new('RedrawDebugNormal', colors.debug, colors.none, styles.NONE)
141 - Group.new('RedrawDebugClear', colors.debug, colors.none, styles.NONE)
142 - Group.new('RedrawDebugComposed', colors.debug, colors.none, styles.NONE)
143 - Group.new('RedrawDebugRecompose', colors.debug, colors.none, styles.NONE)
105 + Group.new("RedrawDebugNormal", colors.debug, colors.none, styles.NONE)
106 + Group.new("RedrawDebugClear", colors.debug, colors.none, styles.NONE)
107 + Group.new("RedrawDebugComposed", colors.debug, colors.none, styles.NONE)
108 + Group.new("RedrawDebugRecompose", colors.debug, colors.none, styles.NONE)

neovim/lua/theme/nvim_tree_colors.lua

Deleted
deleted file mode 100644
1 -return function(Group, groups, colors, styles)
2 - Group.new('NvimTreeFolderName', colors.normal, colors.none, styles.NONE)
3 - Group.new('NvimTreeFolderIcon', colors.normal, colors.none, styles.NONE)
4 - Group.new('NvimTreeExecFile', colors.normal, colors.none, styles.NONE)
5 - Group.new('NvimTreeImageFile', colors.normal, colors.none, styles.NONE)
6 - Group.new('NvimTreeEmptyFolderName', colors.normal, colors.none, styles.NONE)
7 - Group.new('NvimTreeIndentMarker', colors.normal, colors.none, styles.NONE)
8 -end

neovim/lua/theme/terminal_colors.lua

Deleted
deleted file mode 100644
1 -return function(...)
2 - vim.g.terminal_color_0 = '#555555'
3 - vim.g.terminal_color_1 = '#FB467B'
4 - vim.g.terminal_color_2 = '#B8EE92'
5 - vim.g.terminal_color_3 = '#FFCC00'
6 - vim.g.terminal_color_4 = '#56D6D6'
7 - vim.g.terminal_color_5 = '#B954B8'
8 - vim.g.terminal_color_6 = '#00D5A7'
9 - vim.g.terminal_color_7 = '#CED5E5'
10 - vim.g.terminal_color_8 = '5555555'
11 - vim.g.terminal_color_9 = '#FB467B'
12 - vim.g.terminal_color_10 = '#B8EE92'
13 - vim.g.terminal_color_11 = '#FFCC00'
14 - vim.g.terminal_color_12 = '#56D6D6'
15 - vim.g.terminal_color_13 = '#B954B8'
16 - vim.g.terminal_color_14 = '#00D5A7'
17 - vim.g.terminal_color_15 = '#CED5E5'
18 -end

neovim/lua/theme/treesitter_colors.lua

Modified
1 1 return function(Group, groups, colors, styles)
2 - Group.new('TSFloat', groups.Float, groups.Float, groups.Float)
3 - Group.new('TSFunction', groups.Function, groups.Function, groups.Function)
4 - Group.new('TSType', groups.Type, groups.Type, groups.Type)
5 - Group.new('TSTypeBuiltin', groups.Type, groups.Type, groups.Type)
6 - Group.new('TSLabel', groups.Label, groups.Label, groups.Label)
7 - Group.new('TSCharacter', groups.Character, groups.Character, groups.Character)
8 - Group.new(
9 - 'TSConditional',
10 - groups.Conditional,
11 - groups.Conditional,
12 - groups.Conditional
13 - )
14 - Group.new('TSConstant', groups.Constant, groups.Constant, groups.Constant)
15 - Group.new('TSConstBuiltin', groups.Constant, groups.Constant, groups.Constant)
16 - Group.new('TSConstMacro', groups.Constant, groups.Constant, groups.Constant)
17 - Group.new('TSFuncBuiltin', groups.Function, groups.Function, groups.Function)
18 - Group.new('TSMethod', groups.Function, groups.Function, groups.Function)
19 - Group.new('TSStructure', groups.Structure, groups.Structure, groups.Structure)
20 - Group.new(
21 - 'TSTagDelimiter',
22 - groups.Delimiter,
23 - groups.Delimiter,
24 - groups.Delimiter
25 - )
26 - Group.new('TSNumber', groups.Number, groups.Number, groups.Number)
27 - Group.new('TSFuncMacro', groups.Function, groups.Function, groups.Function)
28 - Group.new('TSInclude', groups.Include, groups.Include, groups.Include)
29 - Group.new('TSKeyword', groups.Keyword, groups.Keyword, groups.Keyword)
30 - Group.new('TSException', groups.Exception, groups.Exception, groups.Exception)
31 - Group.new('TSBoolean', groups.Boolean, groups.Boolean, groups.Boolean)
32 - Group.new('TSError', groups.Error, groups.Error, groups.Error)
33 - Group.new('TSString', groups.String, groups.String, groups.String)
34 - Group.new('TSStringEscape', colors.normal, colors.none, styles.NONE)
35 - Group.new('TSStringRegex', colors.normal, colors.none, styles.NONE)
36 - Group.new('TSField', colors.normal, colors.none, styles.NONE)
37 - Group.new('TSParameter', colors.normal, colors.none, styles.NONE)
38 - Group.new('TSVariable', colors.normal, colors.none, styles.bold)
39 - Group.new('TSPunctBracket', colors.normal, colors.none, styles.NONE)
40 - Group.new('TSOperator', colors.normal, colors.none, styles.NONE)
41 - Group.new('TSProperty', colors.normal, colors.none, styles.NONE)
2 + Group.new("TSString", colors.normal, colors.none, styles.bold + styles.italic)
3 + Group.new("TSStringEscape", groups.TSString, colors.accent_weak, groups.TSString)
4 + Group.new("TSStringRegex", groups.TSString, colors.accent_weak, groups.TSString)
5 + Group.new("TSStringSpecial", groups.TSString, colors.debug, groups.TSString)
6 + Group.new("TSConstBuiltin", groups.TSString, groups.TSString, groups.TSString)
7 + Group.new("TSNumber", groups.TSString, groups.TSString, groups.TSString)
8 + Group.new("TSBoolean", groups.TSString, groups.TSString, groups.TSString)
9 + Group.new("TSFloat", groups.TSString, groups.TSString, groups.TSString)
10 + Group.new("TSCharacter", groups.TSString, groups.TSString, groups.TSString)
12 + Group.new("TSKeyword", colors.minor, colors.none, styles.NONE)
13 + Group.new("TSKeywordFunction", groups.TSKeyword, groups.TSKeyword, groups.TSKeyword)
14 + Group.new("TSKeywordOperator", groups.TSKeyword, groups.TSKeyword, groups.TSKeyword)
15 + Group.new("TSKeywordReturn", groups.TSKeyword, groups.TSKeyword, styles.bold + styles.underline)
16 + Group.new("TSConditional", groups.TSKeyword, groups.TSKeyword, groups.TSKeyword)
17 + Group.new("TSRepeat", groups.TSKeyword, groups.TSKeyword, groups.TSKeyword)
18 + Group.new("TSLabel", groups.TSKeyword, groups.TSKeyword, groups.TSKeyword + styles.bold)
19 + Group.new("TSException", groups.TSKeyword, groups.TSKeyword, groups.TSKeyword)
21 + Group.new("TSMethod", colors.normal, colors.none, styles.NONE)
23 + Group.new("TSPunctBracket", colors.minor, colors.none, styles.NONE)
24 + Group.new("TSPunctDelimiter", groups.TSPunctBracket, groups.TSPunctBracket, groups.TSPunctBracket)
25 + Group.new("TSPunctSpecial", groups.TSPunctBracket, groups.TSPunctBracket, groups.TSPunctBracket)
26 + Group.new("TSOperator", groups.TSPunctBracket, groups.TSPunctBracket, groups.TSPunctBracket)
28 + Group.new("TSVariable", colors.normal, colors.none, styles.NONE)
30 + Group.new("TSType", colors.normal, colors.none, styles.NONE)
31 + Group.new("TSTypeBuiltin", groups.TSType, groups.TSType, groups.TSType)
33 + Group.new("TSComment", colors.important, colors.none, styles.bold + styles.italic)
35 + Group.new("TSNote", colors.accent_strong, colors.none, styles.bold)
37 + Group.new("TSFunction", colors.normal, colors.none, styles.NONE)
38 + Group.new("TSConstant", colors.normal, colors.none, styles.NONE)
39 + Group.new("TSConstMacro", colors.normal, colors.none, styles.NONE)
40 + Group.new("TSFuncBuiltin", colors.normal, colors.none, styles.NONE)
41 + Group.new("TSStructure", colors.normal, colors.none, styles.NONE)
42 + Group.new("TSTagDelimiter", colors.normal, colors.none, styles.NONE)
43 + Group.new("TSFuncMacro", colors.normal, colors.none, styles.NONE)
44 + Group.new("TSInclude", colors.normal, colors.none, styles.NONE)
45 + Group.new("TSError", colors.error, colors.none, styles.NONE)
46 + Group.new("TSField", colors.normal, colors.none, styles.NONE)
47 + Group.new("TSParameter", colors.normal, colors.none, styles.NONE)
48 + Group.new("TSProperty", colors.normal, colors.none, styles.NONE)
50 + Group.new("TSNone", colors.none, colors.none, styles.NONE)
51 + Group.new("TSParameterReference", colors.normal, colors.none, styles.NONE)
52 + Group.new("TSConstructor", colors.normal, colors.none, styles.NONE)
53 + Group.new("TSAnnotation", colors.normal, colors.none, styles.NONE)
54 + Group.new("TSAttribute", colors.normal, colors.none, styles.NONE)
55 + Group.new("TSNamespace", colors.normal, colors.none, styles.NONE)
56 + Group.new("TSSymbol", colors.normal, colors.none, styles.NONE)
57 + Group.new("TSText", colors.normal, colors.none, styles.NONE)
58 + Group.new("TSStrong", colors.normal, colors.none, styles.NONE)
59 + Group.new("TSEmphasis", colors.normal, colors.none, styles.NONE)
60 + Group.new("TSUnderline", colors.normal, colors.none, styles.underline)
61 + Group.new("TSStrike", colors.normal, colors.none, styles.NONE)
62 + Group.new("TSMath", colors.normal, colors.none, styles.NONE)
63 + Group.new("TSTextReference", colors.normal, colors.none, styles.NONE)
64 + Group.new("TSEnvironment", colors.normal, colors.none, styles.NONE)
65 + Group.new("TSEnvironmentName", colors.normal, colors.none, styles.NONE)
66 + Group.new("TSTitle", colors.normal, colors.none, styles.NONE)
67 + Group.new("TSLiteral", colors.normal, colors.none, styles.NONE)
68 + Group.new("TSURI", colors.normal, colors.none, styles.NONE)
69 + Group.new("TSWarning", colors.warning, colors.none, styles.NONE)
70 + Group.new("TSDanger", colors.debug, colors.none, styles.NONE)
71 + Group.new("TSTag", colors.normal, colors.none, styles.NONE)
72 + Group.new("TSTagAttribute", colors.normal, colors.none, styles.NONE)
73 + Group.new("TSPlaygroundFocus", colors.important, colors.none, styles.NONE)
74 + Group.new("TSQueryLinterError", colors.error, colors.none, styles.NONE)
75 + Group.new("TSPlaygroundLang", colors.normal, colors.none, styles.NONE)

nushell/nurc

Modified
19 19 alias grep = rg
21 21 # CUSTOM LITTLE JAVA COMMANDS
22 -alias sha = java (build-string $nu.env.DOTFILES /tools/ sha.java)
23 22 alias aes = java (build-string $nu.env.DOTFILES /tools/ aes.java)
24 -alias uuid = java (build-string $nu.env.DOTFILES /tools/ random_uuid.java)
25 23 alias download = java (build-string $nu.env.DOTFILES /tools/ download.java)
26 24 alias download_jar = java (build-string $nu.env.DOTFILES /tools/ download_jar.java)

tools/random_uuid.java

Deleted
deleted file mode 100644
1 -import static java.lang.System.*;
3 -import java.awt.*;
4 -import java.awt.datatransfer.*;
5 -import java.io.*;
6 -import java.util.*;
8 -class random_uuid {
9 - public static void main(String[] __) {
10 - out.println("The following random UUID has been copied to the clipboard!");
11 - var uuid = UUID.randomUUID();
12 - out.println(uuid);
13 - var clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
14 - var content = new StringSelection(uuid.toString());
15 - clipboard.setContents(content, content);
16 - }
17 -}

tools/sha.java

Deleted
deleted file mode 100644
1 -import static java.lang.System.out;
2 -import static java.lang.System.err;
3 -import static java.lang.System.in;
5 -import java.nio.file.*;
6 -import java.nio.charset.*;
7 -import java.security.*;
8 -import java.io.*;
9 -import java.util.*;
10 -import java.util.function.*;
11 -import java.util.stream.*;
13 -/**
14 - * <h1>sha CLI</h1>
15 - * <p>
16 - * This command line tool generates cryptographic check sums for any given input.
17 - * Supported algorithms are:
18 - * <ul>
19 - * <li> MD5
20 - * <li> SHA-1
21 - * <li> SHA-224
22 - * <li> SHA-256
23 - * <li> SHA-384
24 - * <li> SHA-512
25 - * <li> SHA3-224
26 - * <li> SHA3-256
27 - * <li> SHA3-384
28 - * <li> SHA3-512
29 - * </ul>
30 - * <p>
31 - * Usage: The first argument to the coommand must be a specifier for the algorithm, that is to be used.
32 - * The specifier will be fuzzily matched on a best effort basis, so that humans do not have to remember
33 - * exact specifiers.
34 - * For example, 'md' will match 'MD5', 'sha' and 'sh' will match 'SHA-1', '512' will match 'SHA-512' and
35 - * so on.
36 - * <p>
37 - * The second input can either be a path to a file, in which case its contents will be checksummed, or an
38 - * arbitrary string.
39 - * If the second input is not given, it is assumed to take the <code>standard input stream</code> as input.
40 - * An error will occur, if the <code>stdin</code> is empty in such a case.
41 - * <p>
42 - * The output of the command will be the checksum with the selected algorithm prefixed, seperated by a ':'.
43 - * Ex: <code>sha512:12A447B5954E0AF6FB0A6E95779EAE3151B09EFF9EFADBB23F116294674A19E861A3FCCDC3EC8A445C814BB3A3A93603A74D07B4E397B7D66E22211AD67943C3</code>
44 - */
45 -class sha {
46 - public static void main(String[] command_line_arguments) throws Exception {
47 - if(command_line_arguments.length == 0)
48 - {
49 - err.println("no input given");
50 - help();
51 - throw fail();
52 - }
53 - if(command_line_arguments.length > 2)
54 - {
55 - err.println("too many inputs given");
56 - help();
57 - throw fail();
58 - }
59 - if(command_line_arguments.length == 1)
60 - {
61 - var algorithm = guess_algorithm(command_line_arguments[0]);
62 - print_checksum(algorithm, in);
63 - }
64 - else if(command_line_arguments.length == 2)
65 - {
66 - var algorithm = guess_algorithm(command_line_arguments[0]);
67 - var input = command_line_arguments[1];
68 - var path = as_valid_path(input);
69 - if(path != null)
70 - {
71 - print_checksum(algorithm, path_to_stream(path));
72 - }
73 - else
74 - {
75 - print_checksum(algorithm, string_to_stream(input));
76 - }
77 - }
78 - }
80 - private static MessageDigest guess_algorithm(String guess) throws Exception
81 - {
82 - var available_algorithms = new String[]{"MD5", "SHA-1", "SHA-224", "SHA-256", "SHA-384", "SHA-512", "SHA3-224", "SHA3-256", "SHA3-384", "SHA3-512"};
83 - var highest_scoring_algorithm_index = 0;
84 - var highest_score = 0;
85 - //we iterate the algorithms in reverse, so that later algos get prio in case of equal scores
86 - for(int i = available_algorithms.length-1; i >= 0; --i)
87 - {
88 - var score = guess_score(available_algorithms[i], guess);
89 - if(score > highest_score)
90 - {
91 - highest_score = score;
92 - highest_scoring_algorithm_index = i;
93 - }
94 - }
95 - if(highest_score == 0)
96 - {
97 - err.println("the given algorithm '"+ guess +"' could not be matched with any of: "+ Arrays.toString(available_algorithms));
98 - help();
99 - throw fail();
100 - }
101 - return MessageDigest.getInstance(available_algorithms[highest_scoring_algorithm_index]);
102 - }
104 - private static int guess_score(String name, String guess){
105 - /*
106 - * we start by rating every guess with the max score.
107 - * subsequent transformations of the name and comparisons with the guess lower the score by half.
108 - * if a comparison yields true, we return the current score.
109 - * if no comparison yields true, the score is 0.
110 - */
111 - var normalized_guess = guess.toLowerCase().strip();
112 - var transformed_name = name;
113 - var score = Integer.MAX_VALUE;
114 - //the first comparison uses only stripped guess, in case human bothered to enter the algorithm exactly correct
115 - if(transformed_name.equals(guess.strip()))
116 - {
117 - return score;
118 - }
119 - score = score / 2;
120 - transformed_name = transformed_name.toLowerCase();
121 - if(transformed_name.equals(normalized_guess))
122 - {
123 - return score;
124 - }
125 - score = score / 2;
126 - transformed_name = transformed_name.replaceAll("-","");
127 - if(transformed_name.equals(normalized_guess))
128 - {
129 - return score;
130 - }
131 - score = score / 2;
132 - if(transformed_name.endsWith(normalized_guess))
133 - {
134 - return score;
135 - }
136 - score = score / 2;
137 - if(transformed_name.startsWith(normalized_guess))
138 - {
139 - return score;
140 - }
141 - score = score / 2;
142 - if(transformed_name.contains(normalized_guess))
143 - {
144 - return score;
145 - }
146 - return 0;
147 - }
149 - private static void print_checksum(MessageDigest algorithm, InputStream input_stream) throws IOException
150 - {
151 - byte [] buffer = new byte[4092];
152 - while( (buffer = input_stream.readNBytes(4092)).length > 0 )
153 - {
154 - algorithm.update(buffer);
155 - }
156 - out.println(algorithm.getAlgorithm() + ":" + bytesToHex(algorithm.digest()));
157 - }
159 - private static Path as_valid_path(String path)
160 - {
161 - try
162 - {
163 - var real_path = Path.of(path);
164 - if(
165 - Files.exists(real_path) &&
166 - Files.isReadable(real_path) &&
167 - Files.isRegularFile(real_path)
168 - )
169 - {
170 - return real_path;
171 - }
172 - }
173 - catch(InvalidPathException __)
174 - {
175 - //do nothing if path is invalid
176 - }
177 - return null;
178 - }
180 - private static InputStream path_to_stream(Path path) throws IOException
181 - {
182 - return Files.newInputStream(path);
183 - }
185 - private static InputStream string_to_stream(String string)
186 - {
187 - return new ByteArrayInputStream(string.getBytes());
188 - }
190 - private static String bytesToHex(byte[] bytes) {
191 - byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
192 - byte[] hexChars = new byte[bytes.length * 2];
193 - for (int i = 0; i < bytes.length; i++)
194 - {
195 - int v = bytes[i] & 0xFF;
196 - hexChars[i * 2] = HEX_ARRAY[v >>> 4];
197 - hexChars[i * 2 + 1] = HEX_ARRAY[v & 0x0F];
198 - }
199 - return new String(hexChars, StandardCharsets.UTF_8);
201 - private static void help()
202 - {
203 - out.println("Generate cryptographic checksum");
204 - out.println("");
205 - out.println("Usage:");
206 - out.println("\t> sha <algorithm> <string>");
207 - out.println("\t> sha <algorithm> <path>");
208 - out.println("\t> cat somefile.txt | sha <algorithm>");
209 - out.println("");
210 - out.println("Algorithms:");
211 - out.println("\t- md5");
212 - out.println("\t- sha1");
213 - out.println("\t- sha224");
214 - out.println("\t- sha256");
215 - out.println("\t- sha384");
216 - out.println("\t- sha512");
217 - out.println("\t- sha3-224");
218 - out.println("\t- sha3-256");
219 - out.println("\t- sha3-384");
220 - out.println("\t- sha3-512");
221 - }
223 - private static Exception fail() {
224 - System.exit(-1);
225 - /*
226 - * This is in fact dead code, but a neat trick to misuse the throw keyword for control flow.
227 - * Since the compiler has no concept of a terminating function, like System.exit, we fake it by
228 - * pretending this function throws.
229 - */
230 - return new RuntimeException();
231 - }

topgrade/topgrade.windows.toml

Modified
30 30 # Custom commands
31 31 [commands]
32 +"Refresh dotfiles" = "java W:/misc/dotfiles/bootstripper.java W:/misc/dotfiles"
33 34 # Leider scheint der eingebaute "tldr" step von topgrade nicht für meine Version von TLDR funktionieren
34 35 "TLDR" = "tldr --update"