#!/bin/bash set -e function __addline { local filename=$1 shift local line="$@" grep "^$line\$" $filename >/dev/null || echo $line >> $filename } function _profile { [ -w ~/.bash_profile ] && __addline ~/.bash_profile $@ __addline ~/.profile "$@" __addline ~/.zprofile "$@" } function _path_low { PATH="$1:$PATH" _profile "export PATH='$1'":'"$PATH"' } function _path_high { PATH="$PATH:$1" _profile 'export PATH="$PATH"':"'$1'" } function _path { _path_low $@ }