Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Konfekt / windows10-add-packages.ps1
Last active September 7, 2026 06:21
add useful chocolatey packages after installation of Windows 10/11
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
# remove bloat as in
# https://lifehacker.com/you-can-get-rid-of-windows-bloatware-with-one-command-1848707156
iwr -useb https://git.io/debloat | iex
iwr -useb https://christitus.com/win | iex
@Konfekt
Konfekt / c_compdb.vim
Last active July 17, 2026 02:34
Automatically generate compile_commands.json for clangd Language Server in Vim; put into ~/.vim/ftplugin/
" Generate compile_commands.json for clangd.
" Prefer CMake export, else Ninja compdb, else Bear + Make with optional append.
if exists('b:did_c_compdb_ftplugin') | finish | endif
let b:did_c_compdb_ftplugin = 1
let s:inflight = {}
augroup c_compdb
autocmd! * <buffer>
@Konfekt
Konfekt / single-file-git-with-vim.md
Last active May 30, 2026 13:19
Easily version control a single file under vim
@Konfekt
Konfekt / aichat.vim
Last active May 12, 2026 19:04
Vim commands to pipe text to aichat and open a chat window; use AIChatAppend/Replace/Session to append / replace text or open a terminal session; pass a role by appending s slash, say `AIChatReplace /coder`. Consider abbreviating commands with https://github.com/Konfekt/vim-alias
if !executable('aichat') | finish | endif
function! s:ProcessInstruction(instruction) abort
let instruction = trim(a:instruction)
if instruction[0] ==# '/'
let i = match(instruction..' ', '\s')
if i > 1
" Extract the role and the remaining instruction
let role = instruction[1:i-1]
@Konfekt
Konfekt / mise.sh
Created March 23, 2026 08:24
activate mise under MSYS2 bash/zsh, in particular Git Bash
# To make Mise work in MSYS2/Cygwin, see
# https://github.com/jdx/mise/discussions/3961#discussioncomment-16024383
# -- 1. Locate the mise binary ------------------------------------------
local mise_bin=""
if [[ -n "$MSYSTEM" ]]; then
# MSYS2 / Cygwin: prefer the Windows-native exe resolved through cygpath
local scoop_shim_dir="$(/usr/bin/cygpath -u "$USERPROFILE")/scoop/shims"
local scoop_mise="${scoop_shim_dir}/mise"
@Konfekt
Konfekt / git-worktree-create.sh
Created April 6, 2026 11:44
auto-install common dependencies on git worktree creation
#!/usr/bin/env bash
# git worktrees enable working with differing dependencies:
# auto-install common dependencies on worktree creation by this
# post-checkout hook; drop insto post-checkout.d with multihook :
# https://gist.github.com/Konfekt/d9e86763b0f3febd7b2f7ca589f6c482
set -Eeuo pipefail
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 4))); then
@Konfekt
Konfekt / git-multihook.sh
Last active April 6, 2026 11:34
use global git hooks as fallback to local hooks
#!/usr/bin/env bash
#
# This script is meant to be put into a directory pointed to by core.hooksPath
# in Git 2.9.
# Then for each hook you want to support, create a directory "hookname.d" and
# a symlink "hookname -> stub", and put all scripts for that hook into the
# hookname.d directory.
#
# - ./HOOKNAME.d/*
# - $GIT_CUSTOM_HOOKS_DIR/HOOKNAME.d/*
@Konfekt
Konfekt / grep.vim
Last active April 2, 2026 20:18
Set &grepprg to git-grep inside repo and fall back rg, ugrep or grep outside of it
" Set &grepprg to rg, ugrep, git grep or grep otherwise.
" Assumes a global ignore file `$XDG_CONFIG_HOME/grep/ignore`; create it by,
" say `touch ~/.config/grep/ignore` to ensure its existence.
augroup vimrcGrep
autocmd!
augroup END
" Scheduling niceness on Linux.
let s:scheduler = (has('unix') && executable('chrt') && executable('ionice'))
@Konfekt
Konfekt / find.vim
Created February 21, 2026 10:11
Set &findfunc to git-ls-files inside repo and fall back rg, ugrep or fd outside of it
" Purpose: Fast file finding via 'findfunc', with caching and git-aware file listing.
augroup vimrcFind
autocmd!
augroup END
" Scheduling niceness on Linux.
let s:scheduler = has('unix') && executable('chrt') && executable('ionice') ?
\ 'chrt --idle 0 ionice -c2 -n7 ' : ''
@Konfekt
Konfekt / vim-compile.sh
Last active March 3, 2026 11:23
Compile Vim from source with dynamic Python 3 support for virtual environments
#!/usr/bin/env bash
# trace exit on error of program or pipe (or use of undeclared variable)
set -o errtrace -o errexit -o pipefail # -o nounset
# optionally debug output by supplying TRACE=1
[[ "${TRACE:-0}" == "1" ]] && set -o xtrace
if [[ "${BASH_VERSINFO:-0}" -gt 4 || ( "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 ) ]]; then
shopt -s inherit_errexit
fi