dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Reviews Compare Notes Search Review guide 🧪 new nu command `github-upload-key` 6ba60db552c5ea49c94f0b86328c906c589f6182
Oliver Krylow <o.krylow@isp-insoft.de > · 6 Aug 2021
unsigned
Browse files Compare with HEAD
in order to be able to add ssh keys easily to github without having to
install the github cli, a command was created that can take care of it
via a rest post call. Changed files (6) Diff layout Auto Unified Split
+35 / −3 text lines
3 - - [ ] what to do about ssh and GPG keys? or secrets in general?3 + ## Commands to remember 5 + - sd: search and replace6 + - fd: find files recursively7 + - diskonaut: explore file system visually for large files8 + - btm (bottom): system overview9 + - grep (rg): search file contents10 + - bat: show file content11 + - glow: render markdown in the terminal12 + - tokei: count lines of code13 + - hyperfine: benchmark tool14 + - tldr: tool documentation15 + - grex: regular expression pattern generator16 + - xh: make HTTP requests17 + - watchexec: filesystem watcher18 + - licensor: print a license text19 + - pastel: manage colors20 + - hexyl: terminal hex viewer21 + - gib: generate gitignore files22 + - ix (indexa): global file search23 + - silicon: code pretty picture generator25 + - bandwhich: show network traffic information26 + - so: search Stack Exchange 30 + - [ ] kill thy babbies: remove obsolete java commands. nu has builtins now for checksums and for random uuids31 + - [ ] rewrite bootstripper and java commmands with zig. how to run them? precompile? zig run?35 + - [x] what to do about ssh and GPG keys? or secrets in general?4 36 - [x] say goodbye to GPG, too hard to manage. - [x] say goodbye to GPG, too hard to manage.5 - - [ ] how to handle java tools in `tools` cross platform?37 + - [x ] how to handle java tools in `tools` cross platform?neovim/lua/lsp.lua Modified +6 / −1 text lines
22 22 chain_complete_list = chain_complete_list, chain_complete_list = chain_complete_list,
26 + vim.api.nvim_buf_set_option(buffer_number, 'omnifunc' , 'v:lua.vim.lsp.omnifunc' )25 28 local map = function (type, key, value) local map = function (type, key, value)26 29 vim.api.nvim_buf_set_keymap(buffer_number, type , key, value, { noremap = true , silent = true }) vim.api.nvim_buf_set_keymap(buffer_number, type , key, value, { noremap = true , silent = true })130 - lsp.zls.setup({ on_attach = integrate_into_neovim })133 138 lsp.clangd.setup({ on_attach = integrate_into_neovim }) lsp.clangd.setup({ on_attach = integrate_into_neovim })nushell/nu/config/config.toml Modified +8 / −0 text lines
12 12 startup = [startup = [13 13 "zoxide init nushell --hook prompt | save zoxide.nu" ,"zoxide init nushell --hook prompt | save zoxide.nu" ,14 14 "source zoxide.nu" ,"source zoxide.nu" ,
19 + "nu plugin --load (build-string $nu.env.CARGO_HOME / bin)" ,15 20 "source nurc" ,"source nurc" ,60 65 STARSHIP_SHELL = "nushell" STARSHIP_SHELL = "nushell" nushell/nu/config/nurc Modified +67 / −40 text lines
3 3 # `startup = ["source ~/.config/nushell/nurc"]`# `startup = ["source ~/.config/nushell/nurc"]`5 5 # GLOBAL VARIABLES# GLOBAL VARIABLES6 - let TODO_FILE = D:/Notizen/TODO.md7 - let NURC = (build-string (config path | path dirname ) /nurc)8 - let OS = (sys).host.name6 + let-env NURC = (build-string (pwd ) /nurc)7 + let-env DOTFILES = ((build-string (pwd) /../../..) | path expand)11 10 alias cat = batalias cat = bat16 15 alias grep = rgalias grep = rg18 17 # CUSTOM LITTLE JAVA COMMANDS# CUSTOM LITTLE JAVA COMMANDS19 - alias sha = java_tool sha20 - alias uuid = java_tool random_uuid21 - alias download = java_tool download22 - alias download_jar = java_tool download_jar18 + alias sha = java (build-string $nu.env.DOTFILES /tools/ sha.java)19 + alias aes = java (build-string $nu.env.DOTFILES /tools/ aes.java)20 + alias uuid = java (build-string $nu.env.DOTFILES /tools/ random_uuid.java)21 + alias download = java (build-string $nu.env.DOTFILES /tools/ download.java)22 + alias download_jar = java (build-string $nu.env.DOTFILES /tools/ download_jar.java)24 24 # FUNCTIONS# FUNCTIONS26 - # Wrapper function to launch my custom java tool scripts.27 - # This function handles the different paths the tools can have on different hosts.29 - name: string # name of the custom java tool script without the .java extension 26 + # Uploads a PUBLIC ssh key to GitHub.27 + # Will prompt for the AES encryption password of my dotfiles.28 + def github-upload-key [29 + title: string # Name the key, so you will remember what it is used for30 + key: path # Path to the PUBLIC key31 - # the paths are assumed to have already been linked from dotfiles32 - if $OS == "Windows" {33 - java (build-string X:/tools/ $name .java)32 + if ($key | path exists) {33 + echo (build-string "uploading ssh public key " (ansi gi) $key (ansi reset) " with title " (ansi gb) $title (ansi reset) " to GitHub.") 35 + let encrypted_token_path = (build-string $nu.env.DOTFILES / tresor / 4cef0ce3-da3a-4f16-9412-2d094b4f7445)36 + let decrypted_token_path = (build-string $nu.env.DOTFILES / tresor / gh_token)37 + aes decrypt $encrypted_token_path $decrypted_token_path 38 + let token = (open --raw $decrypted_token_path)39 + let key_content = (open --raw $key)40 + rm -f $decrypted_token_path41 + let result = (do -i { xh --bearer $token https://api.github.com/user/keys (build-string title = $title) (build-string key = $key_content) | from json})42 + if ($result | has-column? errors) {43 + let message = ($result | get message)44 + let url = ($result | get documentation_url)45 + let errors = ($result | get errors)46 + echo (build-string (ansi rb) $message (ansi reset) (char newline))49 + let resource = ($it | get resource)50 + let code = ($it | get code)51 + let field = ($it | get field)52 + let message = ($it | get message)53 + echo (build-string (ansi ui) $resource : $code : $field ": " (ansi rb) $message (ansi reset) (char newline))55 + echo (build-string "Further information: " (ansi yi) $url (ansi reset) (char newline))57 + let id = ($result | get id)58 + let key = ($result | get key)59 + let title = ($result | get title)60 + let created_at = ($result | get created_at)61 + echo (build-string "[" ID : $id "]" " key with title " (ansi gb) $title (ansi reset) " was created at " (ansi yi) $created_at (ansi reset) "." (char newline) )62 + echo (build-string (ansi wu) "PUBLIC SSH KEY:" (ansi reset))64 + echo ($key | ansi gradient --fgstart 0xaefe9f --fgend 0xfefefe)35 - java (build-string ~/.local/tools/ $name .java)68 + echo (build-string "key " (ansi rb) $key (ansi reset) " not found!")
73 + # Shows git log in a pretty table75 + ...rest: string # Extra arguments to git log77 + git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 $rest | lines | split column "»¦«" commit subject name email date | update date { get date | str to-datetime} | sort-by date40 81 program: string program: string42 - if $OS == "Windows" {83 + if (sys).host.name == "Windows" {43 84 start (build-string https://man.cx/ $program) start (build-string https://man.cx/ $program)45 86 exec man $program exec man $program55 96 start (build-string "https://duckduckgo.com/?q=" $query) start (build-string "https://duckduckgo.com/?q=" $query)58 - # Browse and select files in the current directory with an interactive file viewer.60 - ...rest # Arguments will be passed to fzf99 + # Check whether table in pipeline has a column with given name101 + name: string # Name of the column to check for62 - let options = ["--ansi", "--info", "inline"]63 - let layout = ["--height", "100%", "--layout", "reverse", "--border", "--preview-window", "up:1:noborder:66%"]64 - let color = ["--color", "fg:#adadad,fg+:#78aba9,bg:#333333,preview-bg:#222222,border:#547877"]65 - let preview = ["--preview", "bat --color=always --italic-text=always --decorations=never --line-range :300 {}"]66 - fzf $options $layout $color $preview $rest103 + pivot | any? Column0 == $name69 - # Show or add to bugabingas TODO file.71 - --edit (-e) # Edit the todo file in $EDITOR72 - item?: string # New TODO item to append to TODO file106 + # Prints out a list of stuff.107 + # Appends a newline at the end.109 + ...rest: any # list of stuff to echo out74 - if ($edit | empty?) {75 - # How is one supposed to check the optional variable if it is not in scope, when not given?76 - #if $(= $item | empty?) {79 - # appending a line to a file seems kind of sus in nushell right now... ask on discord about this?80 - # open $TODO_FILE | lines | append $(build-string "- " $item) | save $TODO_FILE83 - # Is this the nu way of running dynamic commands?84 - nu --commands (build-string $nu.env.EDITOR " " $TODO_FILE)111 + echo (build-string ($rest | flatten | into string | str collect) )nushell/nu/config/zoxide.nu Modified +13 / −14 text lines
7 9 def __zoxide_prompt [] {def __zoxide_prompt [] {8 - let git = $" (do -i {git rev-parse --abbrev-ref HEAD} | str trim)" 10 + let git = $' (do -i {git rev-parse --abbrev-ref HEAD} | str trim)' 9 11 let git = (if (echo $git | str length) == 0 { let git = (if (echo $git | str length) == 0 {12 14 build-string (char lparen) (ansi cb) $git (ansi reset) (char rparen) build-string (char lparen) (ansi cb) $git (ansi reset) (char rparen)14 - build-string (ansi gb) (pwd) (ansi reset) $git " > " 16 + build-string (ansi gb) (pwd) (ansi reset) $git ' > ' 34 36 def __zoxide_z [...rest:string] {def __zoxide_z [...rest:string] {35 37 if (shells | where active == $true | get name) != filesystem { if (shells | where active == $true | get name) != filesystem {36 38 if (echo $rest | length) > 1 { if (echo $rest | length) > 1 {37 - $" zoxide: can only jump directories on filesystem(char nl)" 39 + $' zoxide: can only jump directories on filesystem(char nl)' 39 41 cd (echo $rest ) cd (echo $rest )43 45 if (echo $rest | length) <= 1 && ($arg0 == '-' || (echo $arg0 | path expand | path exists)) { if (echo $rest | length) <= 1 && ($arg0 == '-' || (echo $arg0 | path expand | path exists)) {46 - cd (zoxide query --exclude (pwd) -- $rest | str trim)48 + cd $ ' (zoxide query --exclude (pwd) -- $rest | str trim)' 52 54 def __zoxide_zi [...rest:string] {def __zoxide_zi [...rest:string] {53 55 if (shells | where active == $true | get name) != filesystem { if (shells | where active == $true | get name) != filesystem {54 - $" zoxide: can only jump directories on filesystem(char nl)" 56 + $' zoxide: can only jump directories on filesystem(char nl)' 56 - cd (zoxide query -i -- $rest | str trim)58 + cd $ ' (zoxide query -i -- $rest | str trim)' +2 / −4 text lines
13 13 import javax .crypto .spec .* ;import javax .crypto .spec .* ;15 15 class aes {class aes {17 16 enum Command { ENCRYPT , DECRYPT }; enum Command { ENCRYPT , DECRYPT };19 17 static Cipher AES_GCM_PKCS5 ; static Cipher AES_GCM_PKCS5 ;20 18 static byte[] SALT = new byte [] { 116 , 104 , 101 , 32 , 109 , 111 , 111 , 110 , 32 , 105 , 115 , 32 , 104 , 105 , 100 , 100 , 101 , 110 , 32 , 105 , 110 , 32 , 112 , 108 , 97 , 105 , 110 , 32 , 118 , 105 , 101 , 119 }; static byte[] SALT = new byte [] { 116 , 104 , 101 , 32 , 109 , 111 , 111 , 110 , 32 , 105 , 115 , 32 , 104 , 105 , 100 , 100 , 101 , 110 , 32 , 105 , 110 , 32 , 112 , 108 , 97 , 105 , 110 , 32 , 118 , 105 , 101 , 119 };21 19 static SecureRandom RANDOM = new SecureRandom (); static SecureRandom RANDOM = new SecureRandom ();119 116 throw exit(); throw exit();155 152 var aes_bytes_count = AES_GCM_PKCS5 .update(read_buffer, 0 , read_bytes_count, aes_buffer); var aes_bytes_count = AES_GCM_PKCS5 .update(read_buffer, 0 , read_bytes_count, aes_buffer); 156 153 output.write(aes_buffer, 0 , aes_bytes_count); output.write(aes_buffer, 0 , aes_bytes_count);