Add cleanliness and freshness to your shell scripts.
XYLITOL plays a role similar to gum, but since it's written in Amber,
it doesn't depend on external binaries and remains fully portable.
Just download and execute xylitol.sh script. (Bash 3.2+ is required.)
ANSI support is required for the terminal.
or use Amber to compile Bash script from amber code.
bash <(curl -sL "https://github.com/amber-lang/amber/releases/download/0.6.0-alpha/install.sh")
tools/build.sh
Source xylitol.sh in your script, app.sh:
#!/usr/bin/env bash
source ./xylitol.sh
name=$(xylitol input --header="Project name")
kind=$(printf 'lib\nbin\n' | xylitol choose --header="Kind")
if xylitol confirm --header="Create $name as a $kind?"; then
echo "creating $name"
fiBundle it into a single file to ship:
tools/bundle.sh app.sh > app-standalone.sh
./app-standalone.shVendor this repository and import from src/lib.ab:
git submodule add https://github.com/zlfn/xylitol.git vendor/xylitolimport { xyl_choose, xyl_confirm } from "vendor/xylitol/src/lib.ab"
main {
const env = xyl_choose(["dev", "staging", "prod"])
if xyl_confirm("Deploy to {env}?") {
echo("deploying to {env}")
}
}choose: Choose an option from a list of choicesfilter: Pick from a list narrowed by typinginput: Prompt the user for input.confirm: Prompt the user for confirmation (yes/no).file: Pick a file from system.
Choose an option from a list of choices
cat songs.txt | ./xylitol.sh choose
cat foods.txt | ./xylitol.sh choose --header="Grocery Shopping"Pick from a list narrowed by typing.
cat cards.txt | ./xylitol.sh filter
ls | ./xylitol.sh filter --no-limit --height=15Prompt for input with a simple command.
./xylitol.sh input > answer.txt
./xylitol.sh input --prompt="Enter password: " --password > password.txtPrompt the user for confirmation (yes/no).
./xylitol.sh confirm && rm file.txt || echo "File not removed"Prompt the user to select a file from the file tree.
./xylitol.sh file ~/.configEvery push drives the built script through a pseudo terminal on:
- Ubuntu / docker bash 3.2, 4.0, 4.3, 4.4, 5.0, 5.2
- macOS / /bin/bash (3.2)