Skip to main content
bash::framehead - A framework for Bash

A framework for Bash

A runtime standard library with a comprehensive (and frankly ridiculous) set of helpers. String manipulation, math, filesystem, networking, git, hardware, colour, terminal, time, process management, and more — all compiled into a single sourceable file. No dependencies beyond what’s already on your system. No installation. Just source it and go.
source ./compiled.sh

string::upper "hello world"      # HELLO WORLD
math::factorial 10               # 3628800
fs::exists ./myfile && echo "found"
timedate::duration::format 3661  # 1h 1m 1s

Why bash::framehead?

Bash is everywhere. But writing robust scripts in Bash usually means reinventing the same wheels — trimming strings, checking if a port is open, formatting durations, hashing a value, reading a file line by line. Every project ends up with its own grab-bag of utility functions, copy-pasted from Stack Overflow and subtly different each time. bash::framehead is that grab-bag, done once and done properly.

Single file

Source one file, get everything. No PATH gymnastics, no install scripts, no package managers.

Modular by design

Don’t need networking? Pull out net.sh. Modules have minimal coupling to each other.

Graceful degradation

Functions check for required tools at runtime and fail cleanly with helpful messages.

Consistent naming

Everything follows module::function convention. No guessing whether it’s str_upper or upper_str.

Core principles

Integer math, string manipulation, array operations — no unnecessary subshells or external tools. Floating point uses bc when needed and says so.
No global state mutation behind your back, no surprise side effects. Functions take input, return output.
As long as runtime.sh is kept, the rest can be mixed and matched freely and the compiler will handle it cleanly.

What’s included

16 modules with approximately 785 functions:

string

115 functions - Case conversion, padding, splitting, encoding, validation, UUID, base64/32

fs

79 functions - Read/write, paths, find, checksums, temp files, symlinks, permissions

timedate

74 functions - Dates, times, durations, timezones, calendars, stopwatch

terminal

74 functions - Cursor, screen, shopt, colour detection, input

colour

65 functions - 4-bit, 8-bit, 24-bit colour, ANSI escapes, strip, wrap

math

53 functions - Integer and float arithmetic, trig, stats, unit conversion

process

51 functions - Query, signal, lock, retry, timeout, jobs, services

runtime

50 functions - OS/arch detection, shell flags, environment introspection

array

42 functions - Slice, sort, filter, set ops, zip, chunk, rotate

net

38 functions - IP, DNS, HTTP, interfaces, fetch, ping, port scan

git

35 functions - Branch, commit, status, stash, tags, remotes

hardware

34 functions - CPU, RAM, GPU, disk, battery, partitions

device

25 functions - Block devices, loop, TTY, mount, filesystem

hash

23 functions - MD5, SHA*, HMAC, FNV, DJB2, CRC32, UUID5, slots

random

22 functions - Native, LCG, xorshift, PCG32, xoshiro, ISAAC, WELL512

pm

5 functions - Package manager abstraction (apt/pacman/brew/dnf/…)

Requirements

  • Bash 4.3+ (associative arrays, namerefs)
  • Bash 5.0+ for a handful of functions (guarded with runtime::is_minimum_bash 5)
  • Standard GNU coreutils (awk, sed, find, sort)
  • Optional: bc for floating point math, curl/wget for networking, openssl for crypto hashes, git for git operations
The framework gracefully degrades when optional dependencies are missing. Functions that require unavailable tools will fail with helpful error messages.

Get started

Installation

Clone the repo and compile the framework into a single file

Quick start

Learn how to use bash::framehead in your scripts

Build docs developers (and LLMs) love