diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-24 20:33:47 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-24 20:33:47 -0400 |
| commit | 4ec3e11b9f542a0239de7bedad9d732b0a20d68b (patch) | |
| tree | 276f2c56ccd63016a6ba1a3b12923d5c631b0555 /configure.sh | |
| parent | 3d5944a732e34b6dd01921dee991dee54af47e18 (diff) | |
| parent | fe6da3015573079229a0da3166eb4b5f36520dbb (diff) | |
Merge branch 'main' of github.com:bruce-hill/bp
Diffstat (limited to 'configure.sh')
| -rw-r--r-- | configure.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/configure.sh b/configure.sh new file mode 100644 index 0000000..13c3830 --- /dev/null +++ b/configure.sh @@ -0,0 +1,32 @@ +#!/bin/env bash + +error() { + printf "\033[31;1m%s\033[m\n" "$@" + exit 1 +} + +default_prefix='/usr/local' +if echo "$PATH" | tr ':' '\n' | grep -qx "$HOME/.local/bin"; then + default_prefix="~/.local" +fi + +printf '\033[1mChoose where to install bp (default: %s):\033[m ' "$default_prefix" +read PREFIX +if [ -z "$PREFIX" ]; then PREFIX="$default_prefix"; fi +PREFIX="${PREFIX/#\~/$HOME}" + +if ! echo "$PATH" | tr ':' '\n' | grep -qx "$PREFIX/bin"; then + error "Your \$PATH does not include this prefix, so you won't be able to run tomo!" \ + "Please put this in your .profile or .bashrc: export PATH=\"$PREFIX/bin:\$PATH\"" +fi + +if command -v doas >/dev/null; then + SUDO=doas +else + SUDO=sudo +fi + +cat <<END >config.mk +PREFIX=$PREFIX +SUDO=$SUDO +END |
