Sh:erpa brings Cargo, OhMy and WebDev worflow to Bash scripting, using the Terminal as a browser!
Because WebDevs should be able to do more than npm run dev
in a terminal, and Bash lovers don't have to be reduced to automations
writers, obviously because I like both sides.
Docs: sherpa-cli.netlify.app - Discord: Community Discord Server
Be sure to have curl, git, gawk instaled (and obviously Bash), then run the installer:
bash -c "$(curl -sLo- https://sherpa-cli.netlify.app/install.sh)"
It will do the following:
- A. Install the CLI tools if not already installed.
- B. Clone the Sh:erpa repo as ~/.sherpa
- C. Add to the $PATH ~/.sherpa/bin
- D. Initiate the SherpaCustomDir as ~/sherpa
Use a Linux Distribution, still a Linux Distro but from WSL2 or MacOS. See the docs for more details.
Once done, restart the terminal.
Upon sherpa new myScript
the following is generated:
# /home/user/sherpa/boxes/myScript
.
├── data
│ └── file.yaml
├── docs
│ └── myScript.md
├── README.md
├── Sherpa.yaml
├── src
│ ├── bin.sh
│ ├── _globals.sh
│ ├── _header.sh
│ ├── _lib.sh
│ ├── _options.sh
│ └── __paths.txt
├── target
│ └── local
│ └── myScript
└── tests
└── example_test.sh
A simple src/bin.sh
file could look like that:
use "std/fmt"
main() {
# Data
dude="$(dataGet "hiker" "name")"
# Template
h1 "Greetings adventurer :)"
hr "+" "-" # ------+------
br
p "Welcome ${txtBlue} ${dude} ${x}!"
}
# Load the main fn if no arguments
[[ "$#" == 0 ]] && main; exit 0
Sh:erpa will merge the partials plus those sourced with use "dir/file"
, generate docs, remove comments and blanks, then build the script and make it available for direct invocations. The tool can be picked-up by WebDevs discovering Bash or experienced shell scripters taking advantage of the build, watch and modularity while writing things their own way.
To create your own local library, use something as sherpa new bob lib
. This would scafold a library version of a BashBox in $SCD/lib
with that structure:
# home/user/sherpa/lib/bob
.
├── data
│ └── example.yaml
├── lib.sh
├── README.md
├── Sherpa.yaml
└── tests
└── example_test.sh
Any .sh file in bob/
can be imported in any BashBox with use "bob/fileName"
.
So far, we can install remote BashBoxes or Libs from Git repositories with:
- BashBox:
sherpa install -n "<someName>" -u "<repoUrl>"
- BashLib:
sherpa install -n "<someName>" -u "<repoUrl>" -t "lib"
More details in the Documentation, and some available repos to play with soon listed here. If you intend to share some code, great :) come on the Discord Server for timely updates about the publishing part.
Check the Sh:erpa Website or come talk in the Discord, but some included features are:
- Modular + build-step workflow
- Pug-like semantic formating
- Non verbose styling options
- CRUD operations on .yaml files
- Fetch API data and use JSON in Bash
- CDN-like imports for remote Libs
- Integrated UnitTests suite
- Docs generation from comments
- Install/Up/Remove remote BashBox or Lib
- Source local libs with
use "dir/file"
- Helpers for env variables or package data
- Helper for
Are you sure? (y/n)
confirm - ...to name some of them.
🔗 | Command | Description |
---|---|---|
🔗 | sherpa |
Dashboard. List of local/remote scripts & libs |
🔗 | sherpa new <myPackage> |
Create a BashBox directory and script |
🔗 | sherpa new <myPackage> lib |
Create a BashLib directory and library file |
🔗 | sherpa rmBox <boxName> |
Delete a local BashBox and clean registers |
🔗 | sherpa rmLib <libName> |
Delete a local BashLib and clean registers |
🔗 | sherpa install ... |
See docs. Installing a remote BashBox or Lib |
🔗 | sherpa uninstall ... |
See docs. Uninstalling a remote BashBox or Lib |
🔗 | sherpa update <boxName> |
Update an installed BashBox |
🔗 | sherpa upLib <libName> |
Update an installed BashLib |
🔗 | sherpa self-update |
Update sh:erpa itself to the lastes version |
🔗 | sherpa init |
Just like 'new' but from an existing directory |
🔗 | sherpa b, build |
Build the myScript.sh and optimise things |
🔗 | sherpa w, watch |
Watching for changes and build on file-save |
🔗 | sherpa r, run |
Build the script and execute it |
🔗 | sherpa t, test |
Run tests from the tests/ dir, with BashUnit |
🔗 | sherpa self-test |
Run Sh:erpa's tests from ~/.sherpa/tests |
🔗 | sherpa d, doc |
Build .md docs from files in src/, with shDoc & bashDoc |
🔗 | sherpa compile |
Compile myScript.sh to a binary, using SHC |
🔗 | sherpa e, edit bin |
Open the src/bin.sh file |
🔗 | sherpa e, edit opt |
Open the src/_options.sh file |
🔗 | sherpa e, edit yaml |
Open the Sherpa.yaml file |
🔗 | sherpa e, edit basecamp |
Open the ~/.sherpa/basecamp.sh file |
🔗 | sherpa aliases |
List/edit the aliases created with Aliasman |
🔗 | sherpa links |
List the Symlinks in ~/.sherpa/bin. (Old command) |
Since relative paths are used, some commands need to be used from a package root directoy: build, watch, run, test, doc, compile, edit.
Upon first install, some aliases are created via Aliasman. They can be visualised and eventually changed via sherpa aliases
command, wich is just a shortcut for aliasman -e
and opens the file storing them (with the default editor, like vim).
alias | replace | effect |
---|---|---|
s | sherpa | Shorter s commands |
sdd | cd $HOME/.sherpa | Jump into the Sherpa Dot Dir |
scd | cd $HOME/sherpa | Jump into the Sherpa Custom Dir |
boxes | cd $HOME/sherpa/boxes | Jump into the local Boxes Dir |
After having created a BashBox with s new <myScript>
, you can:
- Jump into the directory:
boxes && cd myScript
- Open the main file:
s e bin
- or any other command you need from the Root.
Special shoutout to every person who has contributed code and genius ideas to the computing world since the first second of the Unix timestamp, making todays coding possible. Plus...
- Rust Cargo: For the perfect package management workflow.
- OhMyBash/ZSH: For the core/custom architecture inspiration.
- Webinstall.dev: For making the install possible via the awesome webi tool.
- Integrated projects: BashUnit, shdoc, bashdoc, SHC, Pathman, Aliasman, WatchExec, ...
- The non-dev people around me, enduring my talks about CLI, WebDev & how interesting Sh:erpa can be. They all hope that the Discord will be active enough so I could spare them.