# vim: ft=sh sw=2 ts=2 sts=2
prependpath() {
paths="$1"
toadd="$2"
case ":$paths:" in
*:"$toadd":*)
echo "$paths"
;;
*)
echo "$toadd${paths:+:$paths}"
;;
esac
}
# Set the Cargo installation directory.
export CARGO_INSTALL_ROOT="$HOME/.local/cargo"
# Setup PATH.
# shellcheck disable=SC2123
PATH=""
# System paths.
PATH="$(prependpath "$PATH" /sbin)"
PATH="$(prependpath "$PATH" /bin)"
PATH="$(prependpath "$PATH" /usr/sbin)"
PATH="$(prependpath "$PATH" /usr/bin)"
PATH="$(prependpath "$PATH" /usr/bin/core_perl)"
PATH="$(prependpath "$PATH" /usr/bin/vendor_perl)"
PATH="$(prependpath "$PATH" /usr/local/sbin)"
PATH="$(prependpath "$PATH" /usr/local/bin)"
PATH="$(prependpath "$PATH" /usr/local/go/bin)"
# This is for emscripten. Whhhyyyyyyyyyyy is it in /usr/lib? Wtf?
PATH="$(prependpath "$PATH" "/usr/lib/emscripten")"
# macOS paths
PATH="$(prependpath "$PATH" "$HOME/tmp/nvim-osx64/bin")"
# These come from my m2 mac mini via homebrew.
if [ -r "/opt/homebrew" ]; then
PATH="$(prependpath "$PATH" "/opt/homebrew/bin")"
PATH="$(prependpath "$PATH" "/opt/homebrew/sbin")"
fi
# My paths.
PATH="$(prependpath "$PATH" "$CARGO_INSTALL_ROOT/bin")"
PATH="$(prependpath "$PATH" "$HOME/bin")"
PATH="$(prependpath "$PATH" "$HOME/bin/x86_64")"
PATH="$(prependpath "$PATH" "$HOME/bin/aarch64")"
PATH="$(prependpath "$PATH" "$HOME/rust/ripgrep/target/release")"
export PATH
# If homebrew was installed in /opt, then it wants all these vars set to
# point it in the right direction.
if [ -r "/opt/homebrew" ]; then
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
# This apparently tells C/C++ compilers where to find header files?
# Not sure if it's appropriate to set this unconditionally, alas...
export CPATH="/opt/homebrew/include"
fi