Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Konfekt / uq.vim
Last active October 6, 2024 18:13
uq: grep interactively in (Neo)vim
" Add the following snippet to your vimrc or put it into (Neo)Vim's plugin dir
" to grep interactively in the current work dir.
" Open the topmost file in (Neo)Vim by hitting <F2>.
" Requires [ugrep](https://github.com/Genivia/ugrep), a drop-in alternative to grep
" similar to ripgrep.
let s:term = has('nvim') ? 'term' : 'term ++close'
let s:cmd = 'ugrep --config --query --no-confirm --view='..shellescape(v:progpath)
let s:cleanup = has('nvim') ? 'autocmd TermClose <buffer=abuf> if !v:event.status |bwipeout!| endif' : 'redraw!'
@Konfekt
Konfekt / zypper-aliases.sh
Last active September 26, 2024 06:47
Opensuse Zypper packagement aliases
#!/usr/bin/env bash
command -v zypper >/dev/null 2>&1 || return 1
# Zypper {{{1
zcommands=(
licenses ps shell source-download tos vcmp if patch-info pattern-info product-info pt se wp
)
len=${#zcommands[*]}
for (( i=0; i<len; i++ )); do
@Konfekt
Konfekt / apt-aliases.sh
Last active September 26, 2024 07:15
apt / apt-* / dpkg command-line aliases
#!/bin/bash
command -v apt >/dev/null 2>&1 || return 1
# apt commands {{{
apt_commands=(
"ls list"
"cl changelog"
"se search"
@Konfekt
Konfekt / better_gx.vim
Last active September 27, 2024 06:24
Open links and files in browser
" Better gx to open URLs.
"
" Adapted from https://github.com/habamax/.vim/blob/d5087779fee4a7372c1dd2c407674997fdb1268d/autoload/os.vim
" to use in particular :Open command from https://gist.github.com/Konfekt/8e484af2955a0c7bfe82114df683ce0f
" See also https://gist.github.com/AndrewRadev/1ba9eba62df82d616fc8040338c4c4e1
" URL regexes
let s:regex_url = '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}'
func! s:GetURL() abort
@Konfekt
Konfekt / filepicker.md
Last active November 3, 2024 05:52
Open files selected in LF/Yazi/Ranger/NNN in (Neo)Vim with :FilePicker
@Konfekt
Konfekt / project-local-viminfo.md
Last active September 21, 2024 05:48
Project-Local Viminfo
@Konfekt
Konfekt / msys2-pacman-packages.sh
Created August 21, 2024 20:44
Install a batch of useful MinGW tools
#!/bin/sh
pacman -S \
--needed \
base-devel \
mingw-w64-ucrt-x86_64-toolchain \
cmake \
mingw-w64-ucrt-x86_64-cmake-gui \
\
ctags \
@Konfekt
Konfekt / fix.py
Created May 23, 2024 12:29
let ChatGPT suggest fixes to spewn errors
#!/usr/bin/env python3
"""
Adaption of https://github.com/tom-doerr/fix/blob/main/main.py
This script executes a program.
If the program throws an error, the script generates suggestions
for fixing the error.
"""
@Konfekt
Konfekt / swap-alt-win-tab.ahk
Created April 27, 2024 20:04
Swap Win+Tab and Alt+Tab on Windows with Autohotkey v2
; Swap Alt+Tab and Win+Tab
; From https://www.autohotkey.com/boards/viewtopic.php?style=19&p=548067&sid=dfc532a1b55a0d25862c8ee98674e0db#p548067
#HotIf WinActive("ahk_class XamlExplorerHostIslandWindow")
*!Tab::Send("{Alt Down}{Right}")
~*Alt Up::Send("{Enter}")
#HotIf
*!Tab::#Tab
; From https://www.autohotkey.com/docs/v2/Hotkeys.htm#AltTabWindow
@Konfekt
Konfekt / bkp.sh
Created April 27, 2024 10:59
backup a file or restore it if it ends in a bkp extension
#!/usr/bin/env bash
# for each file, either back it up or restore it, in case it ends in a bkp extension
for f in "$@"; do
p="${f%/}"
[ "$p" != "${p%.bkp}" ] &&
cp --archive --interactive --update --verbose "$p" "${p%.bkp}" ||
cp -aiuv "${p}" "$p.bkp"
done; }