diff options
| author | Mike Vink <ivi@vinkies.net> | 2025-03-16 14:47:51 +0000 |
|---|---|---|
| committer | Mike Vink <ivi@vinkies.net> | 2025-03-16 14:47:51 +0000 |
| commit | f97604691d2741e7c5ead501669070cbfbcf9885 (patch) | |
| tree | 4f60025c00b7cb3e2f9f5f906f81f879a1201d4e | |
| parent | cfd4078df7f09db64a4309abadfd6dd08287929b (diff) | |
add container scripts
| -rw-r--r-- | .config/kak/kakrc | 23 | ||||
| -rw-r--r-- | .config/ksh/ksh.kshrc | 11 | ||||
| -rwxr-xr-x | .local/bin/bootstrap-container | 3 | ||||
| -rwxr-xr-x | .local/bin/collect-docker-execers | 5 | ||||
| -rwxr-xr-x | .local/bin/pns | 2 | ||||
| -rwxr-xr-x | .local/bin/write-docker-execers | 2 |
6 files changed, 43 insertions, 3 deletions
diff --git a/.config/kak/kakrc b/.config/kak/kakrc index 02d52e2..8ab64eb 100644 --- a/.config/kak/kakrc +++ b/.config/kak/kakrc @@ -18,3 +18,26 @@ hook global BufSetOption filetype=python %{ set-option buffer formatcmd 'ruff format -' hook buffer -group format BufWritePost .* format } + +define-command delete-buffers-matching -params 1..2 %{ + evaluate-commands %sh{ + cmd=delete-buffer + if [ "$1" = -f ] + then cmd=delete-buffer! + shift + fi + + buffers_escaped=$(eval printf '%s\\n' "$kak_quoted_buflist" | grep "$@" | sed "s/'/''/g") + if [ -z "$buffers_escaped" ] + then echo fail no matching buffer + else { + nl=$(printf '\n.') + IFS=${nl%.} + printf '%s\n' "$buffers_escaped" | + while read bufname + do { + printf "$cmd '%s'\n" "$bufname" + }; done + } fi + } +} diff --git a/.config/ksh/ksh.kshrc b/.config/ksh/ksh.kshrc index 40ec46c..22c0ed2 100644 --- a/.config/ksh/ksh.kshrc +++ b/.config/ksh/ksh.kshrc @@ -14,12 +14,16 @@ lfcd () { [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" fi } +clear-screen-saving-contents-in-scrollback() { + sh -c 'printf "\e[H\e[22J"' +} +# Loses kill buffer which is a bit sad. +bind -m ^L="^E ^A^K clear-screen-saving-contents-in-scrollback^J^Y^B^D" bind -m ^O=' mcd^J' bind -m ^X^F=' REPLY="$(vis-open .)"; [ -z "$REPLY" ] || cd "$REPLY"^J' # Emacs mode clear chops off multline prompts. export PS1="$(hostname):\$(pwd-short)\$(prompt-git)\$(prompt-tf)\n jobs(\j) # " -bind -m ^L="^A^K clear^J" export HISTFILE="$HOME/.history" export HISTCONTROL=ignorespace @@ -31,6 +35,7 @@ export HISTSIZE=100000 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" set -o emacs -[ -f /run/.containerenv ] && [ -n "$PNSH_KAK_AUTOSTART" ] && { - ks s 2>&1 >/dev/null || kc s +[ -f /run/.containerenv ] && ! [ -z "$PNSH_KAK_AUTOSTART" ] && { + eval "set -- $PNSH_KAK_AUTOSTART" + kak "$@" } diff --git a/.local/bin/bootstrap-container b/.local/bin/bootstrap-container new file mode 100755 index 0000000..294d138 --- /dev/null +++ b/.local/bin/bootstrap-container @@ -0,0 +1,3 @@ +#!/bin/sh +echo "/Users/ivi/.okshnew/execers" | entr -n collect-docker-execers /_ & +sleep infinity diff --git a/.local/bin/collect-docker-execers b/.local/bin/collect-docker-execers new file mode 100755 index 0000000..dd4b458 --- /dev/null +++ b/.local/bin/collect-docker-execers @@ -0,0 +1,5 @@ +#!/bin/sh +set -- $(cat "$1") +if [ $# -gt 0 ] +then eval "ps eax -o pid,ppid,user,cmd | grep '^\s\+[0-9]\+\s\+0\s.*' | grep -v -e '^\s\+1\+\s\+0\s' $(for pid; do printf -- '-e HOSTPID=%s ' "$pid"; done) | sed -En 's/^\s+([0-9]+).*/\1/p' | xargs -r kill -s SIGKILL" +fi diff --git a/.local/bin/pns b/.local/bin/pns new file mode 100755 index 0000000..1d31dc3 --- /dev/null +++ b/.local/bin/pns @@ -0,0 +1,2 @@ +#!/bin/sh +oksh -c 'pn exec bootstrap-container &' diff --git a/.local/bin/write-docker-execers b/.local/bin/write-docker-execers new file mode 100755 index 0000000..d26e6ba --- /dev/null +++ b/.local/bin/write-docker-execers @@ -0,0 +1,2 @@ +#!/bin/sh +ps Aeww | grep 'docker exec' | grep -o 'HOSTPID=\S*' | cut -d= -f2 |
