A small library of things that are often required in shellscripts. Written for zsh
, not bash
!
Start your script with:
#!/usr/bin/env zsh
set -euo pipefail
if [[ ! -f ~/.cache/shlib/shlib-v0.1.0.sh ]]; then
mkdir -p ~/.cache/shlib/
curl --fail --silent -L https://github.com/jkrafczyk/shlib/releases/download/v0.1.0/lib.bundle.sh -o ~/.cache/shlib/shlib-v0.1.0.sh
fi
source ~/.cache/shlib/shlib-v0.1.0.sh
- Clone this repository somewhere
- Source the
lib.sh
file in your script - Load required components using
shlib:module:load
Example script:
source ~/lib/shlib/lib.sh
shlib:module:load font
echo "Hello, $(shlib:font:set bold fg-yellow)colorful$(shlib:font:reset) world!"
Functionality related to loading other modules.
Meta-module - doesn't do anything itself, just loads all other supported modules
Text color and font manipulation for terminal output (ANSI control sequences).
Display "usage" messages and terminate the script.
Download external dependencies for use in a script.