Skip to main content
Skip to main content

Setup argsh

There are three ways to setup argsh:

  • Install argsh (globally): It will install argsh (globally), so you can use it from anywhere.
  • Source argsh in your shell: Source argsh in your Bash script as a library.
  • Just copy parts of argsh: You can just copy the parts of argsh that you need and use them in your script.

Install argsh (globally)

This method allows you to load argsh easaly via a shebang in your script.

#!/usr/bin/env argsh
# shellcheck shell=bash
# vim: filetype=bash

Also the argsh script is a wrapper around the argsh docker image. This gives you the ability to use the following options to help you to write nice scripts:

  • test - Run the tests for your script
  • lint - Lint your script
  • docs - Generate documentation for your script
  • coverage - Generate a coverage report
  • minify - Minify your script (experimental)
Note

If you use argsh as executer (shebang) you have to include ${ARGSH_SOURCE} in the call check.

[[ "${0}" != "${BASH_SOURCE[0]}" && -z "${ARGSH_SOURCE}" ]] || main "${@}"

Globally

You can install argsh globally by running the following command:

curl -sL https://min.arg.sh | sudo tee /usr/local/bin/argsh > /dev/null
sudo chmod +x /usr/local/bin/argsh

Project based

You can also install argsh project based using direnv. The recommended pattern is to have a directory .bin in your project root and add it to your PATH using direnv.

curl -sL https://min.arg.sh > .bin/argsh
chmod +x .bin/argsh

Bootstrap a new project

If you want to quickly bootstrap a new project with argsh just do this

bash -c "$(curl -sL https://get.arg.sh)"

This will setup

  • a .bin directory in your project root with argsh
  • a test to help you get started with testing
  • a scripts directory with an example script and test
  • a .github/workflows directory with a GitHub Actions workflow
  • a .envrc to initialize your environment

Source argsh in your shell

You can source argsh in your Bash script.

curl -sL https://get.arg.sh > argsh.sh

Then, in your script, you can source it like this:

source argsh.sh

Just copy parts of argsh

Goto the library overview and copy the parts of argsh that you need and use them in your script.

Next Steps

Was this section helpful?