Skip to content

thibmaek/oyster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oyster

bash version 5 Latest release Build status License

The shell is your oyster!

Utilitily library for writing bash scripts. Think Javascripts Lodash but in Bash. This exposes some verbose functions you can use in a script to make code more readable. Supports sourcing from scripts or the shell, as well as executing scripts via the oyster shebang

Bash is powerful but its API is horrible. Oyster is for you if you are also tired of printf "%s" "${$1^^}":

# Uppercasing a string in Bash:
$ printf "%s" "${$1^^}"

# Uppercasing a string with oyster:
$ oy::str.upper "$1"

Table of Contents

Install

Automatic install

A convenience install script is provided so you can directly install from the command line:

$ curl -fsSL https://github.com/thibmaek/oyster/raw/main/install.sh | bash -

Manually

Download the latest release from the releases page and put somewhere on your filesystem:

$ mkdir -p /usr/local/opt/oyster
$ curl -O https://github.com/thibmaek/oyster/releases/download/v1.1.0/oyster-1.1.0.tar.gz
$ tar xvf oyster-1.1.0.tar.gz -C /usr/local/opt/oyster && cd /usr/local/opt/oyster/oyster-1.1.0
$ make install

This will install oyster in /usr/local/bin/oyster. If you have ~/bin sourced on the path you can also run make install_user to install it there.

Confirm your installation worked (after rehashing your shell):

$ oyster --version
oyster version: 1.1.0

Because Oyster is a pure Bash implementation putting it in /usr/local/bin or anywhere else known to the shell PATH will merely act as a symlink under the hood. If ~/.oyster is deleted, Oyster will stop working because the symlink breaks.

Usage

Oyster script

You can use it as a shebang in scripts. Your shell will look for oyster on the path, source all utilities and then execute your bash code just like a regular bash script with the added utilities:

#! /usr/bin/env oyster
set -e

oy::str.upper "uppercase me"

Sourcing oyster from a regular bash script

If you want to bypass executing scripts via oyster you can also just source oyster's 'module' in your own scripts to make the utilities available:

#!/usr/bin/env bash
set -e

source "$(oyster --where).sh"

API

Thanks

A lot of this is prior art from the Home Assistant team. They created Bashio which provides the base modular layer that oyster also uses.

Their usage however is more steered towards creating a library for usage within Home Assistant add-ons where oyster sets itself apart as a general purpose bash scripting library.

Contributing

See CONTRIBUTING.md

License

MIT

For more info, see license file