# Eryn Wells # vim:ft=zsh: prepend_to_path() { local should_export_path=1 while getopts "e" opt; do case $opt in "e") should_export_path=1;; "+e") should_export_path=0;; *) >&2 echo "$0: unknown option '$opt'" esac done local path_to_add=$@[$OPTIND] if [[ -d "$path_to_add" ]]; then path=("$path_to_add" $path) if (( $should_export_path )); then export path fi return 0 fi return 1 } prepend_to_path "$@"