This repository contains a collection of bash tools that I maintain for various tasks on a range of different linux machines. Some tools have a specific use-case
whilst others are more generic and could be imported into any existing script or project.
They have been organised as a library of related tools and should, for the most part, be imported via the entry script bashtools.lib.sh if you plan on using them together in a project. This entry script will import all libraries from the lib directory, all of their functions will be available in your scripts immediately. All of the library functions are namespaced to facilitate ease-of-use.
lib- Tools can be handpicked from these folders and imported into projects as-is or the entire repository can be cloned into a folder and referenced from there. In that case, the scripts in the repository may reference eachother and will only work like that if they remain within the repository. If the structure is changed or individual scripts are moved elsewhere, note that internal references/includes may need to be updated/removed. Again, the simplest import method is to source the library entry script into your project.
bin- These are command line tools with options/arguments for several different tasks. They depend on various functions from the library itself. These are designed to be run at the command line, not sourced into other files. The tools all have a help text that is available with the
-hflag. If you make use of these tools, again, the simplest method would be to clone the repository, leave the structure unchanged and simply add thisbindirectory to your path, allowing for very easy system-wide usage.
- These are command line tools with options/arguments for several different tasks. They depend on various functions from the library itself. These are designed to be run at the command line, not sourced into other files. The tools all have a help text that is available with the
There are several global variables that are used by various parts of the library, these can be set inside your project or at the command line. They all have default values which are set in bashtools.lib.sh. Globals that can be modified are:
BSHT_PATH_LOG_FILEBSHT_FLAG_QUIETBSHT_FLAG_DEBUGBSHT_FLAG_NO_ROOTBSHT_FLAG_LOG_SIMPLEBSHT_FLAG_LOG_FILE_ENABLED
bin/py_install.sh- installs Python from source; accepts URL to tarball or just a version number for automatic download; extensive help dialog accessible with-h
lib/core/error.sh- error handling and capturelib/core/logging.sh- terminal and file based logginglib/general/utils.sh- general purpose utility functions (memory, disk space, arrays etc)lib/python/utils.sh- functions related to python management/interaction (building, venv, module testing etc)lib/os/dietpi/utils.sh- functions targetting DietPi OS specifically
To make use of the library functions, the simplest method is to clone the repository and source the entry script into your project, for example:
source "/full/path/to/bashtools.lib.sh"If you wish to make use of the included binaries/scripts, if you would prefer not to type the full file path everytime you wish to call one, you can add the bin folder to your path, for example:
export PATH=$PATH:/full/path/to/bin- Bash >= 4.3
- curl or wget
- Debian 11+
- DietPi 9+
- Ubuntu 20.04+
This repository is released under GNU General Public License v3.0. The license can be found, in its entirety, within LICENSE at the root of the repository.