#!/usr/bin/env bash if (( `uname` == "Darwin" )); then BIN=/usr/local/bin BASH_COMPLETION_D=/usr/local/etc/bash_completion.d CURL=curl 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 CURL="sudo curl" fi echo "Installing with" $CURL -s https://raw.githubusercontent.com/mchav/with/master/with -o $BIN/with && chmod +x $BIN/with $CURL -s https://raw.githubusercontent.com/mchav/with/master/with.bash-completion -o $BASH_COMPLETION_D/with.bash-completion echo "with successfully installed!"