[zsh] Clean up path functions; init_path wasn't being called after definition
This commit is contained in:
parent
0aaffa1cca
commit
aa6e81fdeb
3 changed files with 46 additions and 27 deletions
|
@ -3,27 +3,37 @@
|
|||
|
||||
append_to_path() {
|
||||
local should_export_path=1
|
||||
local verbose=0
|
||||
|
||||
while getopts "e" opt; do
|
||||
while getopts "ve" opt; do
|
||||
case $opt in
|
||||
"e") should_export_path=1;;
|
||||
"+e") should_export_path=0;;
|
||||
*) >&2 echo "$0: unknown option '$opt'"
|
||||
"v") verbose=1;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
local result=1
|
||||
local path_to_add=$@[$OPTIND]
|
||||
|
||||
if [[ -d "$path_to_add" ]]; then
|
||||
path+="$path_to_add"
|
||||
|
||||
if (( $should_export_path )); then
|
||||
export path
|
||||
if (( $verbose )); then
|
||||
echo "Appending $path_to_add to \$path"
|
||||
fi
|
||||
|
||||
return 1
|
||||
path+="$path_to_add"
|
||||
else
|
||||
if (( $verbose )); then
|
||||
echo "$path_to_add doesn't exist"
|
||||
fi
|
||||
result=0
|
||||
fi
|
||||
|
||||
return 0
|
||||
if (( $should_export_path )); then
|
||||
export path
|
||||
fi
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
append_to_path "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue