2013-12-31 15:48:42 +00:00
|
|
|
# set user installation paths
|
2014-01-08 04:13:29 +00:00
|
|
|
if [[ -d ~/.autojump ]]; then
|
|
|
|
path=(~/.autojump/bin ${path})
|
|
|
|
fpath=(~/.autojump/functions/ ${fpath})
|
2012-02-08 00:48:24 +00:00
|
|
|
fi
|
2012-11-03 23:27:41 +00:00
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
|
|
|
# set homebrew installation paths
|
2014-01-08 04:13:29 +00:00
|
|
|
if command -v brew && [[ -d "$(brew --prefix)/share/zsh/site-functions" ]]; then
|
|
|
|
fpath=("$(brew --prefix)/share/zsh/site-functions" ${fpath})
|
|
|
|
fi
|
2012-02-08 00:48:24 +00:00
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
2014-01-08 04:13:01 +00:00
|
|
|
# set error file location
|
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
|
|
export AUTOJUMP_ERROR_PATH=~/Library/autojump/errors.log
|
|
|
|
elif [[ -n "${XDG_DATA_HOME}" ]]; then
|
|
|
|
export AUTOJUMP_ERROR_PATH="${XDG_DATA_HOME}/autojump/errors.log"
|
|
|
|
else
|
|
|
|
export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log
|
|
|
|
fi
|
2013-12-31 15:48:42 +00:00
|
|
|
|
2014-01-11 19:54:39 +00:00
|
|
|
if [[ ! -d ${AUTOJUMP_ERROR_PATH:h} ]]; then
|
|
|
|
mkdir -p ${AUTOJUMP_ERROR_PATH:h}
|
2014-01-11 12:58:07 +00:00
|
|
|
fi
|
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
|
|
|
# change pwd hook
|
2013-12-30 22:27:34 +00:00
|
|
|
autojump_chpwd() {
|
2014-01-11 12:58:07 +00:00
|
|
|
if [[ -f "${AUTOJUMP_ERROR_PATH}" ]]; then
|
|
|
|
autojump --add "$(pwd)" >/dev/null 2>${AUTOJUMP_ERROR_PATH} &!
|
|
|
|
else
|
|
|
|
autojump --add "$(pwd)" >/dev/null &!
|
|
|
|
fi
|
2009-03-30 07:34:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-17 03:50:39 +00:00
|
|
|
typeset -gaU chpwd_functions
|
2013-02-01 21:00:26 +00:00
|
|
|
chpwd_functions+=autojump_chpwd
|
2009-04-16 14:00:11 +00:00
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
2013-12-30 23:44:39 +00:00
|
|
|
# default autojump command
|
2013-12-30 22:27:34 +00:00
|
|
|
j() {
|
2012-06-29 04:50:25 +00:00
|
|
|
if [[ ${@} == -* ]]; then
|
|
|
|
autojump ${@}
|
|
|
|
return
|
|
|
|
fi
|
2012-04-02 12:58:43 +00:00
|
|
|
|
2012-12-15 04:58:20 +00:00
|
|
|
local new_path="$(autojump ${@})"
|
2014-01-08 04:13:29 +00:00
|
|
|
if [[ -d "${new_path}" ]]; then
|
2012-04-02 12:58:43 +00:00
|
|
|
echo -e "\\033[31m${new_path}\\033[0m"
|
|
|
|
cd "${new_path}"
|
|
|
|
else
|
|
|
|
echo "autojump: directory '${@}' not found"
|
|
|
|
echo "Try \`autojump --help\` for more information."
|
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
2012-12-15 04:58:20 +00:00
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
2013-12-30 23:44:39 +00:00
|
|
|
# jump to child directory (subdirectory of current path)
|
2013-12-30 22:27:34 +00:00
|
|
|
jc() {
|
2012-12-15 04:58:20 +00:00
|
|
|
if [[ ${@} == -* ]]; then
|
2013-12-30 23:44:39 +00:00
|
|
|
autojump ${@}
|
2013-12-31 00:01:04 +00:00
|
|
|
else
|
2013-12-31 14:39:14 +00:00
|
|
|
j $(pwd) ${@}
|
2012-12-15 04:58:20 +00:00
|
|
|
fi
|
|
|
|
}
|
2013-02-01 19:50:52 +00:00
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
2013-12-30 23:44:39 +00:00
|
|
|
# open autojump results in file browser
|
2013-12-30 22:27:34 +00:00
|
|
|
jo() {
|
2013-11-24 22:26:23 +00:00
|
|
|
if [[ ${@} == -* ]]; then
|
2013-12-30 23:44:39 +00:00
|
|
|
autojump ${@}
|
2013-12-31 14:39:14 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
local new_path="$(autojump ${@})"
|
2014-01-08 04:13:29 +00:00
|
|
|
if [[ -d "${new_path}" ]]; then
|
2013-12-31 00:01:04 +00:00
|
|
|
case ${OSTYPE} in
|
|
|
|
linux-gnu)
|
2013-12-31 14:39:14 +00:00
|
|
|
xdg-open "${new_path}"
|
2013-12-31 00:01:04 +00:00
|
|
|
;;
|
|
|
|
darwin*)
|
2013-12-31 14:39:14 +00:00
|
|
|
open "${new_path}"
|
2013-12-31 00:01:04 +00:00
|
|
|
;;
|
|
|
|
cygwin)
|
2013-12-31 14:39:14 +00:00
|
|
|
cygstart "" $(cygpath -w -a ${new_path})
|
2013-12-31 00:01:04 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown operating system." 1>&2
|
|
|
|
;;
|
|
|
|
esac
|
2013-12-31 14:39:14 +00:00
|
|
|
else
|
|
|
|
echo "autojump: directory '${@}' not found"
|
|
|
|
echo "Try \`autojump --help\` for more information."
|
|
|
|
false
|
2013-11-24 22:26:23 +00:00
|
|
|
fi
|
2013-02-01 19:50:52 +00:00
|
|
|
}
|
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
2013-12-30 23:44:39 +00:00
|
|
|
# open autojump results (child directory) in file browser
|
2013-12-30 22:27:34 +00:00
|
|
|
jco() {
|
2013-02-01 19:50:52 +00:00
|
|
|
if [[ ${@} == -* ]]; then
|
2013-12-30 23:44:39 +00:00
|
|
|
autojump ${@}
|
2013-12-31 14:39:14 +00:00
|
|
|
else
|
|
|
|
jo $(pwd) ${@}
|
2013-02-01 19:50:52 +00:00
|
|
|
fi
|
|
|
|
}
|