Skip to content

bash-boost is a set of library functions for bash, useful for both scripting and interactive use. It draws inspiration from the Boost C++ libraries.

License

Notifications You must be signed in to change notification settings

tomocafe/bash-boost

Repository files navigation

bash-boost

bash-boost is a set of library functions for bash, useful for both scripting and interactive use. It draws inspiration from the Boost C++ libraries.

Philosophy

  • Prefer pure-bash solutions
  • Don't reimplement existing bash features, complement them
  • Functions should have a single purpose, without complicated options
  • Avoid cluttering the user's environment

For examples and further details, see CONTRIBUTING.md

Requirements

bash version 4.2 or later.

This has only been tested for Linux. YMMV for other platforms.

Installation

Bootstrap (recommended)

Download and run the interactive bootstrap script to install the latest release. The script will allow you to enter a directory of your choice or you can select from prepopulated locations.

bash <(curl -sSL tomocafe.github.io/bash-boost/bootstrap.sh)

You can rerun this at any time to update an exsting installation.

From release tarball

Download and extract the latest release, then follow the instructions in the Usage section.

From git

Clone this repository and run make. For manpage generation, perl and pandoc are required.

Usage

Source the bash-boost.sh script and use bb_load to load modules and/or packages

source /path/to/bash-boost/latest/bash-boost.sh

bb_load MODULE      # e.g. cli
bb_load MODULE/PKG  # e.g. cli/arg

Alternatively, you can list modules and packages to load by argument when sourcing bash-boost.sh:

source /path/to/bash-boost/latest/bash-boost.sh MODULE MODULE/PKG ...

If you want to distribute bash-boost as a single file, you can use bash-boost-portable.sh and all modules and packages will be available for use. Please use proper attribution if distributing bash-boost. See LICENSE for details.

source /path/to/bash-boost-portable.sh

You may also want to add the included scripts and manpages to your path lists:

bb_load util/env # for bb_appendpathuniq
bb_appendpathuniq PATH "$BB_ROOT/bin"
bb_appendpathuniq MANPATH "$BB_ROOT/man"

Organization

bash-boost consists of the following modules, each with different packages

  • cli - for command-line (script) use
    • arg - for parsing command line arguments
    • color - for printing text in color
    • input - for handling user input
    • msg - for messaging and logging
    • progress - for creating progress bars
  • interactive - for interactive use
    • cmd - miscellaneous interactive commands
    • prompt - dynamic shell prompt
    • bookmark - directory bookmarking system
  • util - general purpose routines
    • env - for checking and setting environment variables
    • file - file and filesystem related operations
    • kwargs - for handling keyword arguments
    • list - common list operations
    • math - common math operations
    • prof - runtime profiling routines
    • string - common string operations
    • time - common time and date operations
    • rand - random number and string generation

You have the choice of loading an entire module, or selecting certain packages from them.

Documentation

Consult the full manual for an exhaustive list of functions defined in each package.

Versioning

This project follows semantic versioning. Any breaking changes must be made in a new major release. New functions are introduced in minor releases. Patch releases only include fixes to existing functions. No documented feature should be regressed in a minor or patch release.

Alternatives

There are a number of different bash libraries out there, including:

About

bash-boost is a set of library functions for bash, useful for both scripting and interactive use. It draws inspiration from the Boost C++ libraries.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published