Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
beep boop

Daniel Douglas ormaaj

🤖
beep boop
View GitHub Profile
View init.bash
#!/bin/bash
if [[ ${KSH_VERSION+${!KSH_VERSION}} == .sh.version ]]; then
typeset -n FUNCNAME=.sh.fun
if builtin pids 2>/dev/null; then
function BASHPID.get { .sh.value=$(pids -f '%(pid)d'); }
elif [[ -r /proc/self/stat ]]; then
function BASHPID.get { read -r .sh.value _ </proc/self/stat; }
else
View .xinitrc
#!/bin/bash
shopt -s extglob lastpipe
shopt -u assoc_expand_once
function xinitrc_main {
typeset myRootPath
if myRootPath=$(dirname "$(readlink -sne -- "${BASH_SOURCE[0]}")") && [[ -d $myRootPath ]]; then
source "${myRootPath}/shell/functions"
@ormaaj
ormaaj / .bash
Created Apr 27, 2022
builtin loader
View .bash
function initializeBuiltins {
typeset libdir=${fsRoot%%+(/)}/usr/lib64
if [[ $(file -b --mime-type -- "${libdir}/ctypes.so") == 'application/x-sharedlib' ]]; then
typeset -a ctypes=(
callback
dlcall
dlclose
dlopen
dlsym
pack
View filemerge.ksh
#!/bin/ksh
typeset -T FileComparer=(
typeset src dst
typeset -a mv diff rm
compound _=(
_Bool unpackComplete=false
_Bool scanComplete=false
)
@ormaaj
ormaaj / minecraft.bash
Created Dec 4, 2021
minecraft function
View minecraft.bash
# Stupid game.
# minecraft -c | -s [ -p ]
function minecraft {
typeset \
jvm=${JAVA_HOME}/bin/java \
worldPath=~/doc/mcdata2 \
serverPath=~/doc/programs/ServerJarStorage/Release\ 1.8/minecraft_server.jar \
clientPath=~/doc/programs/Minecraft.jar
typeset opt OPTARG OPTIND OPTERR=0
View fixperms.bash
# Quickly adds world read permissions to files and world read/write permissions
# to directories recursively. «-u user[:group]» will additionally chmod files
# and directories recursively.
function fixperms {
typeset -a paths
typeset chownUserGroup
until ${1+'false'}; do
case $1 in
-u)
View logproc.ksh
#!/usr/bin/env ksh
typeset -T Record=(
integer uid
integer date=0
typeset description
)
typeset -T Log=(
Record -h '(internal) Array of log records.' -a records
View gist:3b2c7e9f9980cb2d0f1f30b719df010f
NAME
cksum,md5sum,sum - print file checksum and block count
SYNOPSIS
cksum,md5sum,sum [ options ] [ file ... ]
DESCRIPTION
sum lists the checksum, and for most methods the block count, for each file
argument. The standard input is read if there are no file arguments. getconf
UNIVERSE determines the default sum method: att for the att universe, bsd
@ormaaj
ormaaj / Version ABIJM 93v- 2014-12-24
Last active Sep 8, 2021
ksh93v- vs. debian's 2020.0.0+really93u+20120801-9
View Version ABIJM 93v- 2014-12-24
(ins)root@ormaaj-laptop (162321) ~ # /mnt/ormaaj-laptop/ksh93 -c 'typeset -p .sh; print -v .sh; builtin -l'
namespace sh
{
typeset -l -i lineno=0
math=''
op_astbin=/opt/ast/bin
typeset -i pwdfd=10
typeset -C sig=()
typeset -C stats=()
typeset -s -i subshell=0
View multijob.bash
bash -o monitor -O lastpipe /dev/fd/3 3<<\EOF
typeset -A j jobs
n=0
while ((n++ < 3)); do
{ set -m; trap "exit \$n" exit; suspend; } &
jobs+=([$!]=)
done
{ for x in "${!jobs[@]}"; do sleep .2; kill -CONT "$x"; done; } &
until wait -fnp jid "${!jobs[@]}"
(( (${jobs[$jid]+j[\$jid] = }$?) == 0)); do