[zsh] Move func/ directory to zsh/functions
This commit is contained in:
parent
91da2fc583
commit
7c08c5131f
53 changed files with 1 additions and 1 deletions
38
zsh/functions/prepend_to_path
Normal file
38
zsh/functions/prepend_to_path
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
prepend_to_path() {
|
||||
local should_export_path=1
|
||||
local should_be_verbose=0
|
||||
|
||||
while getopts "ve" opt; do
|
||||
case $opt in
|
||||
"e") should_export_path=1;;
|
||||
"+e") should_export_path=0;;
|
||||
"v") should_be_verbose=1;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
local result=1
|
||||
local path_to_add=$@[$OPTIND]
|
||||
|
||||
if [[ -d "$path_to_add" ]]; then
|
||||
if (( $should_be_verbose )); then
|
||||
echo "Prepending $path_to_add to \$path"
|
||||
fi
|
||||
path=("$path_to_add" $path)
|
||||
else
|
||||
if (( $should_be_verbose )); then
|
||||
echo "$path_to_add doesn't exist"
|
||||
fi
|
||||
result=0
|
||||
fi
|
||||
|
||||
if (( $should_export_path )); then
|
||||
export path
|
||||
fi
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
prepend_to_path "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue