From d50de9196a139cdef5b1b78d6983c4ff0a66c337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Schaerer?= Date: Tue, 2 Nov 2010 17:07:10 +0100 Subject: [PATCH] attempt to fix permissions problem when you "su", the prompt_command can stay set, even without autojump getting sourced. Then the user's autojump file changes owner, and a disaster ensues. This is an attempt to fix this problem. --- autojump.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autojump.bash b/autojump.bash index 7bc1696..bf686d7 100644 --- a/autojump.bash +++ b/autojump.bash @@ -27,6 +27,7 @@ _autojump() complete -F _autojump j #data_dir=${XDG_DATA_HOME:-$([ -e ~/.local/share ] && echo ~/.local/share || echo ~)} data_dir=$([ -e ~/.local/share ] && echo ~/.local/share || echo ~) +export AUTOJUMP_HOME=${HOME} if [[ "$data_dir" = "${HOME}" ]] then export AUTOJUMP_DATA_DIR=${data_dir} @@ -41,7 +42,7 @@ then mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null fi -AUTOJUMP='{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null' +AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null' if [[ ! $PROMPT_COMMAND =~ autojump ]]; then export PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; $AUTOJUMP" fi