Reusable Bash libraries extracted from Base.
This repository provides sourceable Bash libraries for scripts that want Base's logging, command execution, filesystem, and Git helper conventions without adopting the full Base workspace control plane.
lib/bash/std/lib_std.shFoundation helpers for logging, error handling, command execution, PATH updates, assertions, prompts, and imports.lib/bash/file/lib_file.shFile editing helpers built on the stdlib.lib/bash/git/lib_git.shGit helper functions built on the stdlib.
Install the library package from the Base Homebrew tap:
brew trust codeforester/base
brew install codeforester/base/base-bash-libsThe trust step is required on Homebrew versions that block formulae from
non-official taps until the tap is trusted. It is safe to run again on machines
that already trust codeforester/base.
Source the installed stdlib from the Homebrew prefix:
base_bash_libs_prefix="$(brew --prefix codeforester/base/base-bash-libs)"
source "$base_bash_libs_prefix/libexec/lib/bash/std/lib_std.sh"Source the stdlib from an absolute path:
source "/path/to/base-bash-libs/lib/bash/std/lib_std.sh"Load companion libraries with absolute imports:
import "/path/to/base-bash-libs/lib/bash/file/lib_file.sh"
import "/path/to/base-bash-libs/lib/bash/git/lib_git.sh"See examples/std-usage.sh for a small standalone script that sources the
stdlib, imports the file helpers, logs progress, and runs a checked command.
Run the full local validation suite:
./tests/validate.shThe suite expects bats and shellcheck to be installed. On macOS:
brew install bats-core shellcheckThis repository is managed by Base.
Common commands:
basectl setup base-bash-libs
basectl check base-bash-libs
basectl doctor base-bash-libs
basectl test base-bash-libs