Skip to content

Instantly share code, notes, and snippets.

@thiagokokada
Last active May 28, 2021 22:36
Show Gist options
  • Save thiagokokada/115b2588ff65a48d54b8832488801c92 to your computer and use it in GitHub Desktop.
Save thiagokokada/115b2588ff65a48d54b8832488801c92 to your computer and use it in GitHub Desktop.
Script that downloads Babashka if not available and runs the file as a Babashka script afterwards
#!/usr/bin/env bash
#_(
bb_dir="$HOME/.bb"
if [ ! -x "$bb_dir/bb" ]; then
echo "Babashka not found. Installing it at $bb_dir directory..."
download_dir="$(mktemp -d)"
trap "rm -rf $download_dir" EXIT
curl "https://raw.githubusercontent.com/babashka/babashka/master/install" -Ssqlo "$download_dir/install"
mkdir -p "$bb_dir"
bash "$download_dir/install" --dir "$bb_dir" --static
fi
exec "$bb_dir/bb" -f "$0" -- "$@"
)
(println "Hello World!")
@verma
Copy link

verma commented May 28, 2021

Very nice, thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment