1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

Set default install to --auto when no arguments passed.

This commit is contained in:
William Ting 2012-11-22 11:21:31 -06:00
parent a84062b42b
commit 904066373b

View File

@ -40,22 +40,21 @@ destdir=
prefix="usr/local" prefix="usr/local"
zshsharedir= zshsharedir=
# If no arguments passed, default to --auto.
if [[ ${#} == 0 ]]; then
set -- "--auto"
fi
# Command line parsing # Command line parsing
while true; do while true; do
case "$1" in case "$1" in
-a|--auto) -a|--auto)
auto=true
force=
shell=`echo ${SHELL} | awk -F/ '{ print $NF }'`
if [[ ${UID} -eq 0 ]]; then
destdir=
prefix=usr
else
destdir=~/.autojump
prefix=
fi
zshsharedir= zshsharedir=
shift if [[ ${UID} -eq 0 ]]; then
set -- "--global" "${@:2}"
else
set -- "--local" "${@:2}"
fi
;; ;;
-b|--bash) -b|--bash)
shell="bash" shell="bash"
@ -159,22 +158,7 @@ fi
# zsh functions # zsh functions
if [[ -z $shell ]] || [[ $shell == "zsh" ]]; then if [[ -z $shell ]] || [[ $shell == "zsh" ]]; then
if [[ $auto ]]; then if [[ -z $zshsharedir ]]; then
# look for writable dir in fpath
success=
fpath=`/usr/bin/env zsh -c 'echo $fpath'`
for f in ${fpath}; do
if [[ -d $f ]] && [[ -w $f ]]; then
zshsharedir=${f:1}
success=true
break
fi
done
if [[ ! $success ]]; then
echo "Error: failed to determine zsh functions dir" 1>&2
exit 1
fi
elif [[ -z $zshsharedir ]]; then
# if not set, use a default # if not set, use a default
if [[ $local ]]; then if [[ $local ]]; then
zshsharedir="${prefix}functions" zshsharedir="${prefix}functions"