Skip to content

Instantly share code, notes, and snippets.

@BlueDrink9
BlueDrink9 / Always reboot to Windows instead of Linux during a Windows update (systemd-boot).md
Last active Mar 13, 2021
Always reboot to Windows instead of Linux during a Windows update (systemd-boot)
View Always reboot to Windows instead of Linux during a Windows update (systemd-boot).md

Motivation

Say you dual boot Windows and Linux, and use the simple and light-weight systemd-boot to switch OS. Say you boot to Linux by default. However, this causes headaches when Windows updates and needs to restart as part of the process, especially if it has to do so multiple times (for example major feature updates).

You could change the default right before you boot

Automatically set Windows as next boot when restarting as part of an Update

Create a script %windir%\System32\update\run\precommit.cmd with the following contents:

@BlueDrink9
BlueDrink9 / vim-jupytext-foldexpr
Last active Apr 10, 2020
Fold percent-style cells (like used by jupytext) in vim
View vim-jupytext-foldexpr
function GetJupytextFold(linenum)
if getline(a:linenum) =~ "^#\\s%%"
" start fold
return ">1"
elseif getline(a:linenum + 1) =~ "^#\\s%%"
return "<1"
else
return "-1"
endif
@BlueDrink9
BlueDrink9 / WSLtty set environment variable on startup
Created Oct 9, 2019
WSLtty set environment variable on startup as a mintty arg
View WSLtty set environment variable on startup
`mintty_args=--WSL="Ubuntu" --configdir="%APPDATA%\wsltty\dropdown_config" -"~" /bin/sh -c "export VARIABLE='value' && $SHELL -il"`
@BlueDrink9
BlueDrink9 / Fix arch EFI boot from windows.md
Last active Feb 1, 2020
Fix arch EFI boot from windows after a windows update messes with the config. Also: how to access efi partition.
View Fix arch EFI boot from windows.md
  1. Open elevated command prompt.

run mountvol b: /s

Change to efi partition with b:

cd loader\entries

edit arch.conf to make any adjustments, like changing the partition.

@BlueDrink9
BlueDrink9 / Pass environment variables through to ssh and tmux each time you log in
Last active Jun 6, 2019
Pass environment variables through to ssh/tmux each time you log in
View Pass environment variables through to ssh and tmux each time you log in
This is a working solution I have found to the problem of updating values like whether you should use a powerline/nerd patched font,
truecolors or what escape codes to use when sshed into a server that knows no specifics about your current terminal.
SSH by default doesn't pass many variables through, with some caveats.
Tmux, also, will not refresh any variables from the underlying shell.
The way it works initally is by aliasing ssh to a function that first runs a command to export the specified options to the ssh shell,
then runs the user's default shell.
Tmux adds an extra layer to this. By default, it will integrate the shell variables on the **first run only**.
Once it's running, and you create new sessions or reattach from a different terminal, nothing changes.
@BlueDrink9
BlueDrink9 / Autohotkey in Onenote - Up and Down.md
Last active Oct 27, 2020
Send up and down in Onenote with Autohotkey
View Autohotkey in Onenote - Up and Down.md

Problem: Autohotkey cannot send up and down in MS Onenote.

ctrl (^) + up and down work, as does sending something like {end}{right}{end}. This is not quite the same functionality though.

Solution: Don't use AHK.

AutoIT, a similar language, for some reason can send up and down to onenote fine. The workaround used for projects like vim for onenote uses precompiled autoit exes, which do exactly this. They are fast, and work well.