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

Test / create errors directory before writing to it.

Closes #249.
This commit is contained in:
William Ting 2014-01-11 06:58:07 -06:00
parent 3d6bf541cf
commit 573c1ea418
2 changed files with 18 additions and 2 deletions

View File

@ -13,6 +13,10 @@ else
export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log
fi fi
if [[ ! -d "$(dirname ${AUTOJUMP_ERROR_PATH})" ]]; then
mkdir -p "$(dirname ${AUTOJUMP_ERROR_PATH})"
fi
# enable tab completion # enable tab completion
_autojump() { _autojump() {
@ -30,7 +34,11 @@ complete -F _autojump j
# change pwd hook # change pwd hook
autojump_add_to_database() { autojump_add_to_database() {
(autojump --add "$(pwd)" >/dev/null 2>${AUTOJUMP_ERROR_PATH} &) &>/dev/null if [[ -f "${AUTOJUMP_ERROR_PATH}" ]]; then
(autojump --add "$(pwd)" >/dev/null 2>${AUTOJUMP_ERROR_PATH} &) &>/dev/null
else
(autojump --add "$(pwd)" >/dev/null &) &>/dev/null
fi
} }
case $PROMPT_COMMAND in case $PROMPT_COMMAND in

View File

@ -20,10 +20,18 @@ else
export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log export AUTOJUMP_ERROR_PATH=~/.local/share/autojump/errors.log
fi fi
if [[ ! -d "$(dirname ${AUTOJUMP_ERROR_PATH})" ]]; then
mkdir -p "$(dirname ${AUTOJUMP_ERROR_PATH})"
fi
# change pwd hook # change pwd hook
autojump_chpwd() { autojump_chpwd() {
autojump --add "$(pwd)" >/dev/null 2>${AUTOJUMP_ERROR_PATH} &! if [[ -f "${AUTOJUMP_ERROR_PATH}" ]]; then
autojump --add "$(pwd)" >/dev/null 2>${AUTOJUMP_ERROR_PATH} &!
else
autojump --add "$(pwd)" >/dev/null &!
fi
} }
typeset -gaU chpwd_functions typeset -gaU chpwd_functions