Skip to content

Instantly share code, notes, and snippets.

View ormaaj's full-sized avatar

Daniel Douglas ormaaj

View GitHub Profile
@ormaaj
ormaaj / getparams.bash
Created December 6, 2025 05:43
nameref auto-mapper
#!/usr/bin/env bash
shopt -s lastpipe extglob expand_aliases
function unset2 {
unset -v "$@"
}
function getparams {
typeset -a v=v[l]=1+l,v
l=_[_=\${#v[@]}%\$#,0] let v
@ormaaj
ormaaj / fstabfmt.bash
Last active December 2, 2025 21:24
fstab generator
#!/usr/bin/env bash
shopt -s extglob lastpipe expand_aliases
typeset -Gx BASH_COMPAT=51
function fstabfmt {
local -; set +m
typeset x y IFS LC_CTYPE=C
typeset -a fields=(source target fstype options freq passno)
typeset -ia w=("${fields[@]/*/0}")
sendfile is not supported for transport <_UnixWritePipeTransport fd=7 idle bufsize=0>
Traceback (most recent call last):
File "/usr/bin/entry/entry_point", line 109, in _run_python
exec(code, exec_scope) # pylint: disable=exec-used
^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 187, in <module>
File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
@ormaaj
ormaaj / localopt.bash
Created October 29, 2025 12:57
simple shopt toggler
#!/usr/bin/env bash
shopt -s lastpipe extglob expand_aliases
function unset2 {
command unset "$@"
}
function localopt {
typeset IFS OPTARG REPLY r os=:v:uso
typeset -i i dn ret=0 OPTIND=1
@ormaaj
ormaaj / globsort.ksh
Created October 26, 2025 06:48
Numeric sort files matching a pattern (bash or ksh93)
if [[ -v KSH_VERSION ]]; then
typeset -n BASH_REMATCH=.sh.match
else
shopt -s extglob lastpipe
enable -f asort{,}
fi
touch file_{7..13}.pdf
unset -v a b
typeset -A a
@ormaaj
ormaaj / binutils
Last active September 30, 2025 21:25
ld xattr hooks
post_src_install() {
local -; set +o monitor -o pipefail
typeset k e r=${EROOT%%+(/)} cpn=${CATEGORY}/${PN}
e=${r:+${r}/}${ED%%+(/)}
typeset -A base=(
[sys-devel/binutils]=bfd
[sys-devel/mold]=mold
[llvm-core/lld]=lld
)
@ormaaj
ormaaj / tmux.conf
Created September 20, 2025 03:43
tmux.conf
# ~/.tmux.conf
if-shell \
'tput -T tmux-256color longname' \
'set -s default-terminal tmux-256color' \
'set -s default-terminal screen-256color'
%hidden trace='strace -DDYYyqqqf'
%hidden el=/usr/bin/execlineb
%hidden bash=/usr/bin/bash
mkfs.vfat -F 32 --codepage=437 -n ESP -- "${d}1"
mkswap -L swap2 --verbose -- "${d}2"
mkfs.btrfs -vf -O extref,skinny-metadata,no-holes -R quota,free-space-tree --csum xxhash -L ormaaj2 -- "${d}3"
@ormaaj
ormaaj / sudoers
Created August 12, 2025 10:43
sudoers
# /etc/sudoers
Defaults !pam_session
Defaults !pam_setcred
Defaults !use_pty
Defaults fdexec
Defaults closefrom_override
Defaults targetpw
root ALL=(ALL:ALL) ALL
ALL ALL=(ALL:ALL) ALL
@ormaaj
ormaaj / .ps
Last active July 23, 2025 20:35
msys2 launcher
PowerShell 7.6.0-preview.4
Loading personal and system profiles took 2730ms.
PS C:\Users\ormaaj> Start-Process -Wait -NoNewWindow -Environment ([Environment]::GetEnvironmentVariables() + @{ MSYSTEM = 'UCRT64'; MSYS2_NOSTART = 'yes'; LOGINSHELL = 'bash'; TERM = 'xterm-direct' }) -FilePath 'C:\msys64\usr\bin\env.exe' -ArgumentList ([string[]]@('-S-- BASH_COMPAT=51 /c/Users/ormaaj/startdbus.bash /ucrt64/bin/konsole.exe'))
+ m /ucrt64/bin/konsole.exe
+ local -
+ [[ m != \m\a\i\n ]]
+ set +m
+ typeset -x BASH_COMPAT=51
+ m
+ local -