code / bp

Lines4.3K C3.3K Markdown541 YAML273 make110 Shell77 Lua54
(32 lines)
1 #!/bin/env bash
3 error() {
4 printf "\033[31;1m%s\033[m\n" "$@"
5 exit 1
6 }
8 default_prefix='/usr/local'
9 if echo "$PATH" | tr ':' '\n' | grep -qx "$HOME/.local/bin"; then
10 default_prefix="~/.local"
11 fi
13 printf '\033[1mChoose where to install bp (default: %s):\033[m ' "$default_prefix"
14 read PREFIX
15 if [ -z "$PREFIX" ]; then PREFIX="$default_prefix"; fi
16 PREFIX="${PREFIX/#\~/$HOME}"
18 if ! echo "$PATH" | tr ':' '\n' | grep -qx "$PREFIX/bin"; then
19 error "Your \$PATH does not include this prefix, so you won't be able to run tomo!" \
20 "Please put this in your .profile or .bashrc: export PATH=\"$PREFIX/bin:\$PATH\""
21 fi
23 if command -v doas >/dev/null; then
24 SUDO=doas
25 else
26 SUDO=sudo
27 fi
29 cat <<END >config.mk
30 PREFIX=$PREFIX
31 SUDO=$SUDO
32 END