2013-12-30 23:44:39 +00:00
|
|
|
# set paths for user installations
|
2012-03-14 22:54:48 +00:00
|
|
|
if [[ -d ${HOME}/.autojump ]]; then
|
|
|
|
path=(${HOME}/.autojump/bin ${path})
|
|
|
|
fpath=(${HOME}/.autojump/functions/ ${fpath})
|
2012-02-08 00:48:24 +00:00
|
|
|
fi
|
2012-11-03 23:27:41 +00:00
|
|
|
|
2012-03-02 00:45:47 +00:00
|
|
|
# set fpath if necessary for homebrew installation
|
2012-11-03 23:27:41 +00:00
|
|
|
command -v brew &>/dev/null \
|
|
|
|
&& [[ -d "`brew --prefix`/share/zsh/site-functions" ]] \
|
|
|
|
&& fpath=(`brew --prefix`/share/zsh/site-functions ${fpath})
|
2012-02-08 00:48:24 +00:00
|
|
|
|
2013-12-30 23:44:39 +00:00
|
|
|
# add change pwd hook
|
2013-12-30 22:27:34 +00:00
|
|
|
autojump_chpwd() {
|
2013-12-30 23:44:39 +00:00
|
|
|
(autojump -a "$(pwd)" &) &>/dev/null
|
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-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 ${@})"
|
2012-04-02 12:58:43 +00:00
|
|
|
if [ -d "${new_path}" ]; then
|
|
|
|
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-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 ${@}
|
|
|
|
return
|
2012-12-15 04:58:20 +00:00
|
|
|
fi
|
2013-12-30 23:44:39 +00:00
|
|
|
|
|
|
|
j $(pwd)/ ${@}
|
2012-12-15 04:58:20 +00:00
|
|
|
}
|
2013-02-01 19:50:52 +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-11-24 22:26:23 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2013-12-30 23:44:39 +00:00
|
|
|
case ${OSTYPE} in
|
|
|
|
linux-gnu)
|
|
|
|
xdg-open "$(autojump $@)"
|
|
|
|
;;
|
|
|
|
darwin*)
|
|
|
|
open "$(autojump $@)"
|
|
|
|
;;
|
|
|
|
cygwin)
|
|
|
|
cygstart "" $(cygpath -w -a $(pwd))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown operating system." 1>&2
|
|
|
|
;;
|
|
|
|
esac
|
2013-02-01 19:50:52 +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 ${@}
|
|
|
|
return
|
2013-02-01 19:50:52 +00:00
|
|
|
fi
|
2013-12-30 23:44:39 +00:00
|
|
|
|
|
|
|
jo $(pwd)/ ${@}
|
2013-02-01 19:50:52 +00:00
|
|
|
}
|