#!/usr/bin/env bash set -euo pipefail if [[ "$(uname)" == "Darwin" ]]; then BIN=/usr/local/bin BASH_COMPLETION_D=/usr/local/etc/bash_completion.d else # check if user is root # and re-exec the script with sudo if not # # equivalent to: [ "$(whoami)" != "root" ] && exec sudo -- "$0" "$@" # bash only, but without external call to whoami # (( EUID != 0 )) && exec sudo -- "$0" "$@" BIN=/usr/bin BASH_COMPLETION_D=/etc/bash_completion.d fi CURL=(curl -fsSL) echo "Installing with" "${CURL[@]}" https://raw.githubusercontent.com/mchav/with/master/with -o "$BIN/with" && chmod +x "$BIN/with" "${CURL[@]}" https://raw.githubusercontent.com/mchav/with/master/with.bash-completion -o "$BASH_COMPLETION_D/with.bash-completion" echo "with successfully installed!"