From fe2dd2c982b6968727929fb6b6f37d42d7a05d1e Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 5 Feb 2021 11:13:25 +0200 Subject: [PATCH 01/18] [zsh] add a timestamp printing function --- zsh/functions.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 88edb32..e008988 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -83,6 +83,7 @@ declare -A date_formats=( compact '%Y%m%d%H%M%S' only-date '%Y-%m-%d' only-time '%H:%M:%S' + timestamp '%s' ) for format_name format in "${(kv)date_formats[@]}"; do From 6dc39b0e04b5f65b801bd26414ae2875c67a7356 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 5 Feb 2021 11:54:51 +0200 Subject: [PATCH 02/18] [nvim] add functions to workaround some interesting behaviors of vim --- nvim/plugin/editing.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index 817f7cc..c042cd2 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -152,6 +152,11 @@ set commentstring=//%s \|xmap # call VisualStarSearch('?')N augroup END + " + command! -nargs=+ Search let @/ = escape(, '/') | normal // + " + command! -nargs=+ SearchLiteral let @/ = '\V'.escape(, '/\') | normal // + " }}} From aed0b5a30eaddf5283b4dd0c5065d86b6795a59b Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 5 Feb 2021 11:57:28 +0200 Subject: [PATCH 03/18] [nvim] fix FixWhitespaceOnSave flooding the search history --- nvim/plugin/files.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvim/plugin/files.vim b/nvim/plugin/files.vim index f07659f..b9266d5 100644 --- a/nvim/plugin/files.vim +++ b/nvim/plugin/files.vim @@ -144,9 +144,9 @@ nnoremap empty(&buftype) ? ":writewall\" : "\" function s:FixWhitespaceOnSave() let l:pos = getpos('.') " remove trailing whitespace - %s/\s\+$//e + keeppatterns %s/\s\+$//e " remove trailing newlines - %s/\($\n\s*\)\+\%$//e + keeppatterns %s/\($\n\s*\)\+\%$//e call setpos('.', l:pos) endfunction " }}} From 7a3bcc5cc61d91353f75dde5399d8c1859b90d97 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sun, 7 Feb 2021 19:49:38 +0200 Subject: [PATCH 04/18] [zsh] use Python 3 by default on macOS --- zsh/path.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zsh/path.zsh b/zsh/path.zsh index 19c4695..16e85bd 100644 --- a/zsh/path.zsh +++ b/zsh/path.zsh @@ -44,9 +44,11 @@ if (( _is_macos )); then if [[ -d "$formula_path/lib/pkgconfig" ]]; then path_prepend pkg_config_path "$formula_path/lib/pkgconfig" fi - done + done; unset formula - unset formula + # Use Python 3 executables by default, i.e. when a version suffix (`python3`) + # is not specified. + path_prepend path /usr/local/opt/python@3/libexec/bin fi if (( _is_macos )); then From 207298c6f148bb1e870d4d349acb090b666f7f2b Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 8 Feb 2021 20:07:02 +0200 Subject: [PATCH 05/18] [ranger] add ranger config --- ranger/rc.conf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ranger/rc.conf diff --git a/ranger/rc.conf b/ranger/rc.conf new file mode 100644 index 0000000..9e4bf36 --- /dev/null +++ b/ranger/rc.conf @@ -0,0 +1,3 @@ +set show_hidden true +set preview_images true +set preview_images_method kitty From 909783441d5fd7991e05b56b1b6e869af3a8ed0a Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 8 Feb 2021 20:07:14 +0200 Subject: [PATCH 06/18] [kitty] stop changing TERM to something non-default --- kitty/kitty.conf | 2 -- 1 file changed, 2 deletions(-) diff --git a/kitty/kitty.conf b/kitty/kitty.conf index d06cc3b..714c9eb 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -35,8 +35,6 @@ inactive_tab_font_style none # Miscellaneous {{{ # Tip: on high-DPI screens the `double` style is more discernible url_style single -# To be honest I don't have even a slightest clue as for why I changed the TERM -term xterm-256color # }}} # macOS-specific settings {{{ From 1abf65b087ff3c22d932647c426373f172877a17 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 8 Feb 2021 21:51:59 +0200 Subject: [PATCH 07/18] [nvim] properly display wavy underlines under spelling mistakes now that I have enabled all termcap features of kitty --- nvim/colors/dotfiles.vim | 13 +++++++++---- nvim/plugin/interface.vim | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/nvim/colors/dotfiles.vim b/nvim/colors/dotfiles.vim index 6ca399f..03ab4e9 100644 --- a/nvim/colors/dotfiles.vim +++ b/nvim/colors/dotfiles.vim @@ -137,10 +137,15 @@ hi! link ctrlsfMatch Search hi! link ctrlsfLnumMatch ctrlsfMatch - call s:hi('SpellBad', 'bg', '', 'undercurl', 0x8) - call s:hi('SpellLocal', 'bg', '', 'undercurl', 0xC) - call s:hi('SpellCap', 'bg', '', 'undercurl', 0xD) - call s:hi('SpellRare', 'bg', '', 'undercurl', 0xE) + let s:is_kitty = $TERM ==# 'xterm-kitty' + let s:spell_fg = s:is_kitty ? '' : 'bg' + let s:spell_bg = s:is_kitty ? 'NONE' : '' + let s:spell_attr = s:is_kitty ? 'undercurl' : '' + call s:hi('SpellBad', s:spell_fg, s:spell_bg, s:spell_attr, 0x8) + call s:hi('SpellLocal', s:spell_fg, s:spell_bg, s:spell_attr, 0xC) + call s:hi('SpellCap', s:spell_fg, s:spell_bg, s:spell_attr, 0xD) + call s:hi('SpellRare', s:spell_fg, s:spell_bg, s:spell_attr, 0xE) + unlet s:is_kitty s:spell_fg s:spell_bg s:spell_attr call s:hi('Sneak', 'bg', 0xB, 'bold', '') hi! link SneakScope Visual diff --git a/nvim/plugin/interface.vim b/nvim/plugin/interface.vim index 3f2e4e2..03693c7 100644 --- a/nvim/plugin/interface.vim +++ b/nvim/plugin/interface.vim @@ -44,9 +44,9 @@ endif let l:cmd = a:cmd if &modified let l:answer = confirm("Save changes?", "&Yes\n&No\n&Cancel") - if l:answer is# 1 " Yes + if l:answer ==# 1 " Yes write - elseif l:answer is# 2 " No + elseif l:answer ==# 2 " No let l:cmd .= '!' else " Cancel/Other return From 32cfe4f0d5220ef29cbadad0cc65b9c483c58d31 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Tue, 9 Feb 2021 12:29:15 +0200 Subject: [PATCH 08/18] [nvim] disable matchpairs in all other JS-like filetypes --- nvim/after/ftplugin/javascriptreact.vim | 1 + nvim/after/ftplugin/typescript.vim | 1 + nvim/after/ftplugin/typescriptreact.vim | 1 + 3 files changed, 3 insertions(+) create mode 100644 nvim/after/ftplugin/javascriptreact.vim create mode 100644 nvim/after/ftplugin/typescript.vim create mode 100644 nvim/after/ftplugin/typescriptreact.vim diff --git a/nvim/after/ftplugin/javascriptreact.vim b/nvim/after/ftplugin/javascriptreact.vim new file mode 100644 index 0000000..2d9e54a --- /dev/null +++ b/nvim/after/ftplugin/javascriptreact.vim @@ -0,0 +1 @@ +source :h/javascript.vim diff --git a/nvim/after/ftplugin/typescript.vim b/nvim/after/ftplugin/typescript.vim new file mode 100644 index 0000000..2d9e54a --- /dev/null +++ b/nvim/after/ftplugin/typescript.vim @@ -0,0 +1 @@ +source :h/javascript.vim diff --git a/nvim/after/ftplugin/typescriptreact.vim b/nvim/after/ftplugin/typescriptreact.vim new file mode 100644 index 0000000..6a77e28 --- /dev/null +++ b/nvim/after/ftplugin/typescriptreact.vim @@ -0,0 +1 @@ +source :h/typescript.vim From bddaea14dd98032b28abb1ab238dc7684466332a Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 12 Feb 2021 10:21:53 +0200 Subject: [PATCH 09/18] [crosscode] add a mod for binding mouse buttons to actions --- crosscode/btw-i-use-arch-mod/prestart.js | 154 +++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/crosscode/btw-i-use-arch-mod/prestart.js b/crosscode/btw-i-use-arch-mod/prestart.js index bc03b9a..9be33fe 100644 --- a/crosscode/btw-i-use-arch-mod/prestart.js +++ b/crosscode/btw-i-use-arch-mod/prestart.js @@ -5,3 +5,157 @@ sc.OPTIONS_DEFINITION['keys-btw-i-use-arch.open-map-menu'] = { hasDivider: true, header: 'btw-i-use-arch', }; + +ig.KEY.MOUSE_LEFT = ig.KEY.MOUSE1; +ig.KEY.MOUSE_RIGHT = ig.KEY.MOUSE2; +ig.KEY.MOUSE_MIDDLE = -6; +ig.KEY.MOUSE_BACK = -7; +ig.KEY.MOUSE_FORWARD = -8; + +// As for the copied implementations of ig.Input#keydown and ig.Input#keyup: +// there is probably a way to avoid copying, most notably by abusing the logic +// of the keyCode check. See, in both methods it is basically the same, just +// with differing event names, but the logic is as follows: if the event is a +// keyboard event, get the `keyCode` property, otherwise check if +// `event.button` is 2, then assume the key is `ig.KEY.MOUSE2`, otherwise +// `ig.KEY.MOUSE1`. This means that I could replace the value of the `MOUSE1` +// constant to the keyCode determined with my custom logic, and so the fallback +// path will read my value, but ultimately I didn't do that because I figured +// there might be other parts of these functions which can use some +// refactoring. +ig.Input.inject({ + keydown(event) { + if ( + ig.system.crashed || + this.isInIframeAndUnfocused() || + (this.ignoreKeyboard && event.type !== 'mousedown') + ) { + return; + } + + if (ig.system.hasFocusLost()) { + if (event.type === 'mousedown') { + ig.system.regainFocus(); + } + return; + } + + if (event.type === 'mousedown') { + this.mouseGuiActive = true; + } + this.currentDevice = ig.INPUT_DEVICES.KEYBOARD_AND_MOUSE; + + if (event.target.type === 'text') { + return; + } + + let keyCode = this.getKeyCodeFromEvent(event); + + if ( + // It's quite interesting that the game kinda supports touch events, but + // they are never actually used in practice. + event.type === 'touchstart' || + event.type === 'mousedown' + ) { + this.mousemove(event); + } + + let action = this.bindings[keyCode]; + if (action != null) { + this.actions[action] = true; + // Not sure what are locks supposed to do. Oh wait, I figured it out: + // this is so that if a button is detected to be pressed in a frame, but + // if an un-press event is caught during the processing of the frame, the + // button... Hmmm, still not sure. Entirety of the game logic blocks the + // main thread, so it's impossible to catch two events during processing + // of the frame. + if (!this.locks[action]) { + this.presses[action] = true; + this.locks[action] = true; + } + event.stopPropagation(); + event.preventDefault(); + } + }, + + keyup(event) { + if ( + ig.system.crashed || + this.isInIframeAndUnfocused() || + (this.ignoreKeyboard && event.type !== 'mouseup') || + event.target.type === 'text' || + (ig.system.hasFocusLost() && event.type === 'mouseup') + ) { + return; + } + + this.currentDevice = ig.INPUT_DEVICES.KEYBOARD_AND_MOUSE; + + let keyCode = this.getKeyCodeFromEvent(event); + + let action = this.bindings[keyCode]; + if (action != null) { + this.keyups[action] = true; + this.delayedKeyup.push(action); + event.stopPropagation(); + event.preventDefault(); + } + }, + + getKeyCodeFromEvent(event) { + switch (event.type) { + case 'keyup': + case 'keydown': + return event.keyCode; + + case 'mouseup': + case 'mousedown': + switch (event.button) { + case 0: + return ig.KEY.MOUSE_LEFT; + case 1: + return ig.KEY.MOUSE_MIDDLE; + case 2: + return ig.KEY.MOUSE_RIGHT; + case 3: + return ig.KEY.MOUSE_BACK; + case 4: + return ig.KEY.MOUSE_FORWARD; + } + } + + // idk, fall back to the left mouse button. That's kind of what the default + // implementation does though. + return ig.KEY.MOUSE_LEFT; + }, +}); + +// Finally, some nice injection places. +sc.KeyBinderGui.inject({ + show(...args) { + this.parent(...args); + window.addEventListener('mousedown', this.bindedKeyCheck, false); + }, + + hide(...args) { + this.parent(...args); + window.removeEventListener('mousedown', this.bindedKeyCheck); + }, + + onKeyCheck(event) { + event.preventDefault(); + + let keyCode = ig.input.getKeyCodeFromEvent(event); + if (ig.interact.isBlocked() || this._isBlackedListed(keyCode)) return; + + // This call was added by me. Just in case. Because the `stopPropagation` + // call in `ig.Input` saved me from re-binds of left/right mouse buttons to + // whatever else other than interactions with menus. + event.stopPropagation(); + + if (this.finishCallback != null) { + this.finishCallback(keyCode, this.isAlternative, false); + } + this.hide(); + }, +}); From 8a4f6f8a4a3be43090914dba05f764a32587f8b3 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 12 Feb 2021 10:43:39 +0200 Subject: [PATCH 10/18] [nvim] disable ESLint integration for Prettier, sync configs --- nvim/coc-languages/javascript.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nvim/coc-languages/javascript.vim b/nvim/coc-languages/javascript.vim index e6b8c5a..98b3f26 100644 --- a/nvim/coc-languages/javascript.vim +++ b/nvim/coc-languages/javascript.vim @@ -5,10 +5,18 @@ let g:coc_user_config['eslint'] = { \ 'filetypes': s:filetypes, \ 'autoFixOnSave': v:true, \ } +" See let g:coc_user_config['prettier'] = { +\ 'printWidth': 100, +\ 'tabWidth': 2, +\ 'useTabs': v:false, +\ 'semi': v:true, \ 'singleQuote': v:true, +\ 'quoteProps': 'as-needed', +\ 'jsxSingleQuote': v:false, \ 'trailingComma': 'all', +\ 'bracketSpacing': v:true, \ 'jsxBracketSameLine': v:true, -\ 'eslintIntegration': v:true, -\ 'disableSuccessMessage': v:true +\ 'arrowParens': 'always', +\ 'disableSuccessMessage': v:true, \ } From 315a95750e19b3afc5cd16ed69d8bd5ef6c97b98 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 12 Feb 2021 10:51:34 +0200 Subject: [PATCH 11/18] [scripts/discord-stream-desktop-audio] allow specifying the audio device --- scripts/discord-stream-desktop-audio | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/discord-stream-desktop-audio b/scripts/discord-stream-desktop-audio index 603e5a4..e80d176 100755 --- a/scripts/discord-stream-desktop-audio +++ b/scripts/discord-stream-desktop-audio @@ -6,6 +6,7 @@ import os guild_id = int(sys.argv[1]) voice_channel_id = int(sys.argv[2]) +pulseaudio_device = sys.argv[3] with open(os.path.expanduser("~/.config/dotfiles/discord-tools-bot-token.txt")) as f: bot_token = f.read().strip() @@ -28,7 +29,7 @@ async def on_ready(): voice_client = await voice_channel.connect() print("connected to {0} ({0.id}) in {1} ({1.id})".format(voice_channel, guild)) - source = discord.FFmpegPCMAudio("default", before_options="-f pulse") + source = discord.FFmpegPCMAudio(pulseaudio_device, before_options="-f pulse") voice_client.play( source, after=lambda e: print("Player error: %s" % e) if e else None ) From 3f40b413f36227dc3ee08bff4f0b2ce6d6c9197d Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 12 Feb 2021 15:27:03 +0200 Subject: [PATCH 12/18] [x11] add my xprofile --- x11/xprofile.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 x11/xprofile.sh diff --git a/x11/xprofile.sh b/x11/xprofile.sh new file mode 100755 index 0000000..eddbe8f --- /dev/null +++ b/x11/xprofile.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +export XDG_MENU_PREFIX=lxde- +export MOZ_USE_XINPUT2=1 +export QT_QPA_PLATFORMTHEME=qt5ct From 4ad73c71542c0e923919ae60545926c5218b11ef Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 12 Feb 2021 21:00:01 +0200 Subject: [PATCH 13/18] [zsh] improve path.zsh loading speed by not calling the entire rustc The effects of this were very significant on my good ol' winchester. --- zsh/path.zsh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/zsh/path.zsh b/zsh/path.zsh index 16e85bd..d6a9bda 100644 --- a/zsh/path.zsh +++ b/zsh/path.zsh @@ -68,17 +68,32 @@ export GOPATH=~/go path_prepend path "$GOPATH/bin" # Rust -path_prepend path ~/.cargo/bin -# check if the Rust toolchain was installed via rustup -if rustup_home="$(rustup show home 2> /dev/null)" && - rust_sysroot="$(rustc --print sysroot 2> /dev/null)" && - [[ -d "$rustup_home" && -d "$rust_sysroot" && "$rust_sysroot" == "$rustup_home"/* ]] -then - # add paths of the selected Rust toolchain - path_prepend fpath "$rust_sysroot/share/zsh/site-functions" - path_prepend manpath "$rust_sysroot/share/man" +if [[ -f ~/.rustup/settings.toml ]]; then + # Make a low-effort attempt at quickly extracting the selected Rust toolchain + # from rustup's settings. The TOML file is obviously assumed to be well-formed + # and syntactically correct because virtually always it's manipulated with the + # use of rustup's CLI. Also a shortcut is taken: strings aren't unescaped + # because Rust toolchain names don't need escaping in strings. + # See also . + if rust_toolchain="$( + awk ' + match($0, /^default_toolchain = "(.+)"$/, matches) { + print matches[1]; + exit; + } + /^\[.+\]$/ { + exit; + } + ' ~/.rustup/settings.toml + )" && [[ -n "$rust_toolchain" ]]; then + rust_sysroot=~/.rustup/toolchains/"$rust_toolchain" + path_prepend path "$rust_sysroot"/bin + path_prepend fpath "$rust_sysroot"/zsh/site-functions + path_prepend manpath "$rust_sysroot"/share/man + fi + unset rust_toolchain rust_sysroot fi -unset rustup_home rust_sysroot +path_prepend path ~/.cargo/bin # add my binaries and completions path_prepend path "${ZSH_DOTFILES:h}/scripts" From 27f9b351c1266210caf6fc4d951c2a52ba3ccd87 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sat, 13 Feb 2021 16:39:18 +0200 Subject: [PATCH 14/18] [zsh] export libs from the installed Rust toolchain as well --- zsh/path.zsh | 18 +++++++++++++++--- zsh/zshrc | 8 -------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/zsh/path.zsh b/zsh/path.zsh index d6a9bda..303370e 100644 --- a/zsh/path.zsh +++ b/zsh/path.zsh @@ -1,9 +1,11 @@ #!/usr/bin/env zsh -# tie these env variables to zsh arrays -typeset -T PKG_CONFIG_PATH pkg_config_path ':' +export PATH +export MANPATH -export PKG_CONFIG_PATH PATH MANPATH +# tie these env variables to zsh arrays +export -T PKG_CONFIG_PATH pkg_config_path ':' +export -T LD_LIBRARY_PATH ld_library_path ':' path_prepend() { if (( $# < 1 )); then @@ -90,6 +92,7 @@ if [[ -f ~/.rustup/settings.toml ]]; then path_prepend path "$rust_sysroot"/bin path_prepend fpath "$rust_sysroot"/zsh/site-functions path_prepend manpath "$rust_sysroot"/share/man + path_prepend ld_library_path "$rust_sysroot"/lib fi unset rust_toolchain rust_sysroot fi @@ -103,3 +106,12 @@ path_prepend fpath "$ZSH_DOTFILES/completions" path_prepend path ~/.local/bin unfunction path_prepend + +# For some reason manpath is not always set when logging with ssh for instance. +# Let's ensure that it is always set and exported. The additional colon ensures +# that the system manpath isn't overwritten (see manpath(1)). +if [[ -n "$MANPATH" && "$MANPATH" != *: ]]; then + # Append a colon if MANPATH isn't empty and doesn't end with a colon already + MANPATH="$MANPATH:" +fi +export MANPATH="$MANPATH" diff --git a/zsh/zshrc b/zsh/zshrc index 3513103..ea8cb05 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -46,14 +46,6 @@ _perf_timer_start "total" fi # }}} -# For some reason manpath is not always set when logging with ssh for instance. -# Let's ensure that it is always set and exported. The additional colon ensures -# that the system manpath isn't overwritten (see manpath(1)), though in reality -# two colons get added for some reason, which is also valid, but means -# something slightly different (again, see manpath(1)). Hope this won't cause -# any problems in the future. -export MANPATH="$MANPATH:" - for script in functions options path env plugins aliases completion zle prompt colorscheme; do _perf_timer_start "$script.zsh" source "$ZSH_DOTFILES/$script.zsh" From 412015d3749fb35c09f26f0a3f8d65d92d9a58ac Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sat, 13 Feb 2021 17:31:01 +0200 Subject: [PATCH 15/18] [zsh] parse rustup settings with a zsh script instead to further improve performance --- zsh/path.zsh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/zsh/path.zsh b/zsh/path.zsh index 303370e..fff9b36 100644 --- a/zsh/path.zsh +++ b/zsh/path.zsh @@ -77,25 +77,28 @@ if [[ -f ~/.rustup/settings.toml ]]; then # use of rustup's CLI. Also a shortcut is taken: strings aren't unescaped # because Rust toolchain names don't need escaping in strings. # See also . - if rust_toolchain="$( - awk ' - match($0, /^default_toolchain = "(.+)"$/, matches) { - print matches[1]; - exit; - } - /^\[.+\]$/ { - exit; - } - ' ~/.rustup/settings.toml - )" && [[ -n "$rust_toolchain" ]]; then + rust_toolchain="" + < ~/.rustup/settings.toml while IFS= read -r line; do + if [[ "$line" =~ '^default_toolchain = "(.+)"$' ]]; then + rust_toolchain="${match[1]}" + break + elif [[ "$line" == \[*\] ]]; then + break + fi + done; unset line + + if [[ -n "$rust_toolchain" ]]; then rust_sysroot=~/.rustup/toolchains/"$rust_toolchain" path_prepend path "$rust_sysroot"/bin path_prepend fpath "$rust_sysroot"/zsh/site-functions path_prepend manpath "$rust_sysroot"/share/man path_prepend ld_library_path "$rust_sysroot"/lib + unset rust_sysroot fi - unset rust_toolchain rust_sysroot + + unset rust_toolchain fi + path_prepend path ~/.cargo/bin # add my binaries and completions From 789d9caefd9e372ff9b54c7e93888d37394e9fad Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sat, 13 Feb 2021 17:51:25 +0200 Subject: [PATCH 16/18] [zsh] parse ~/.ssh/config with a zsh script instead of awk as well --- zsh/completion.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zsh/completion.zsh b/zsh/completion.zsh index 5ae1e87..faa7748 100644 --- a/zsh/completion.zsh +++ b/zsh/completion.zsh @@ -40,9 +40,12 @@ zstyle ':completion:*:processes' force-list always _completion_get_hosts() { print localhost - if [[ -f ~/.ssh/config ]]; then - awk "match(\$0, /^Host[[:blank:]]*/) { print substr(\$0, RLENGTH+1); }" ~/.ssh/config - fi + local line + < ~/.ssh/config while IFS= read -r line; do + if [[ "$line" =~ '^Host[[:blank:]]+(.*)[[:blank:]]*' ]]; then + print -- "${match[1]}" + fi + done } zstyle -e ':completion:*:hosts' hosts 'reply=("${(@f)$(_completion_get_hosts)}")' From faa946c7ccb18d576111b5a4ed89019c15ed9898 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sun, 14 Feb 2021 02:09:05 +0200 Subject: [PATCH 17/18] [zsh] implement update-grub for Arch systems --- zsh/aliases.zsh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index c5227a4..e75e872 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -74,7 +74,12 @@ alias du='du -h' alias df='df -h' alias free='free -h' -alias apt-get="echo -e \"use 'apt' instead of 'apt-get'\nif you really want to use 'apt-get', type '"'\\\\'"apt-get'\" #" +if command_exists apt && command_exists apt-get; then + apt_get_message="use 'apt' instead of 'apt-get' +if you really want to use 'apt-get', type '\\apt-get'" + alias apt-get="echo -E ${(qqq)apt_get_message} #" + unset apt_get_message +fi # editor alias edit="$EDITOR" @@ -97,3 +102,9 @@ alias bin-list-dylib-symbols='nm -gD' # Duplicated as an alias to prevent autocorrection of the real "command" part. # See also scripts/prime-run alias prime-run='__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia ' + +if ! command_exists update-grub; then + # Doesn't exist on Arch by default. Probably implementing this command was + # left as a challenge to the documentation reader. + alias update-grub="grub-mkconfig -o /boot/grub/grub.cfg" +fi From a06b1043762ba3346cd05ead542a177d5c53f3b0 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 15 Feb 2021 16:22:36 +0200 Subject: [PATCH 18/18] [nvim] update the mappings for fugitive --- nvim/plugin/git.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nvim/plugin/git.vim b/nvim/plugin/git.vim index 66ca1dd..901d487 100644 --- a/nvim/plugin/git.vim +++ b/nvim/plugin/git.vim @@ -2,11 +2,12 @@ let g:gitgutter_map_keys = 0 nnoremap gg :G nnoremap g :Git - nnoremap gs :vertical Gstatus - nnoremap gd :Gdiff - nnoremap gb :Gblame - nnoremap gw :Gbrowse + nnoremap gs :vertical Git + nnoremap gd :Gdiffsplit + nnoremap gb :Git blame + nnoremap gw :GBrowse + nnoremap gW :.GBrowse nnoremap gc :Gcommit % - nnoremap gl :Glog - nnoremap gp :Gpush + nnoremap gl :Gclog + nnoremap gp :Git push " }}}