Skip to content

Instantly share code, notes, and snippets.

View izabera's full-sized avatar

Isabella Bosia izabera

  • XTX
  • Flitwick, UK
View GitHub Profile
s|8|.7|g;s|7|.6|g;s|6|.5|g;s|5|.4|g;s|4|.3|g;s|3|.2|g;s|2|.1|g;s|1|.|g;s|.| &|g;s|/|\n|g
@izabera
izabera / ircsed
Last active June 4, 2026 21:19
a simple irc bot written in sed
#!/bin/bash
owner=izabera nick=sedirc network=irc.freenode.net
echo "
# send bot data
1 {
s/.*/nick $nick/p
s/.*/user $nick $nick $nick :$nick/p
s/.*/cat factoids 2>\/dev\/null/e; H
b
@izabera
izabera / 0.README.md
Last active May 8, 2026 15:42
tput codes

This is the table from man 5 terminfo.

Do NOT hardcode terminal escape sequences. Use tput with the cap-names from the table below to get the right code for your terminal.

(P) indicates that padding may be specified

A funky shell thingy that I've never seen before

So you're in posix sh and you want to do the equivalent of this in bash:

foo | tee >(bar) >(baz) >/dev/null

(Suppose that bar and baz don't produce output. Add redirections where needed if that's not the case.)

This is from man bash:

A pipeline is a sequence of one or more commands separated by one of the control operators | or |&. The format for a pipeline is:

[ time [ -p ]] [ ! ] command [ [ | | |& ] command2 ... ]

This is the only place in which ! can appear. It never prefixes commands, it prefixes pipelines.

@izabera
izabera / readfile.md
Last active December 25, 2025 23:54
reading a file line by line in your shell

context: shells want to leave the seek position at the right offset so external commands can continue reading from the same fd


i saw this somewhat surprising tally of syscalls in bash. let's investigate

surprise

one iteration:

  • unblock all signals
@izabera
izabera / recursive_exp.md
Last active December 25, 2025 23:35
recursive expansions

for the latest chapter of what's becoming a blog on the most cursed bash you can imagine, let's do some maths together

euclid's algorithm for gcd could be written like this in python:

>>> def gcd(a, b):
...     if b:
...         return gcd(b, a%b)
... return a

asking gemini to write some cube code

i'm writing another lil cube thing. if you've ever written a rubik's cube simulator/solver, you will know that some parts can be more akin to data than to code. one way or another, you always end up with lots and lots of tables to select the right pieces and move them to the right places. if good code reads like poetry and bad code reads like a phonebook, this is always easily in the top 10 most mind-numbingly boring programs of all time.

@izabera
izabera / 000.md
Created August 12, 2025 03:00
ai reviews my mini webserver

ai reviews my mini webserver

i needed to share a single file so i wrote a quick webserver in bash like any normal person would. it supports head and get, which was all i needed. as far as i'm aware it doesn't misbehave too badly

then i showed it to a bunch of extremely smart phd level agi bots that are going to replace us all and asked them to review it and point out any flaws

@izabera
izabera / magic_namerefs.md
Last active December 25, 2025 23:24
magic namerefs

namerefs (introduced in bash 4.0) act as aliases for other variables

var=meow
declare -n ref=var

echo $ref  # prints meow

ref=moo
echo $var  # prints moo