1#!/usr/bin/env bash 2 3if (( `uname` == "Darwin" )); then 4 BIN=/usr/local/bin 5 BASH_COMPLETION_D=/usr/local/etc/bash_completion.d 6 CURL=curl 7else 8 # check if user is root 9 # and re-exec the script with sudo if not 10 # 11 # equivalent to: [ "$(whoami)" != "root" ] && exec sudo -- "$0" "$@" 12 # bash only, but without external call to whoami 13 # 14 (( EUID != 0 )) && exec sudo -- "$0" "$@" 15 BIN=/usr/bin 16 BASH_COMPLETION_D=/etc/bash_completion.d 17 CURL="sudo curl" 18fi 19 20echo "Installing with" 21$CURL -s https://raw.githubusercontent.com/mchav/with/master/with -o $BIN/with && chmod +x $BIN/with 22$CURL -s https://raw.githubusercontent.com/mchav/with/master/with.bash-completion -o $BASH_COMPLETION_D/with.bash-completion 23echo "with successfully installed!" 24