From 5213506d3cfbc0b320bb4b6b5cd2f2b1464f2b36 Mon Sep 17 00:00:00 2001 From: William Ting Date: Wed, 8 Feb 2012 11:27:43 -1000 Subject: [PATCH] fix bash local installation paths --- autojump.bash | 18 ++++++++++-------- autojump.sh | 12 ++++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/autojump.bash b/autojump.bash index 237b755..914c374 100644 --- a/autojump.bash +++ b/autojump.bash @@ -15,7 +15,7 @@ #along with autojump. If not, see . #This shell snippet sets the prompt command and the necessary aliases -_autojump() +_autojump() { local cur cur=${COMP_WORDS[*]:1} @@ -29,10 +29,9 @@ EOF } complete -F _autojump j -_autojump_files() +_autojump_files() { - if [[ ${COMP_WORDS[COMP_CWORD]} == *__* ]] - then + if [[ ${COMP_WORDS[COMP_CWORD]} == *__* ]]; then local cur #cur=${COMP_WORDS[*]:1} cur=${COMP_WORDS[COMP_CWORD]} @@ -48,21 +47,24 @@ EOF complete -o default -o bashdefault -F _autojump_files cp mv meld diff kdiff3 #determine the data directory according to the XDG Base Directory Specification -if [ -n "$XDG_DATA_HOME" ] -then +if [ -n "$XDG_DATA_HOME" ]; then export AUTOJUMP_DATA_DIR="$XDG_DATA_HOME/autojump" else export AUTOJUMP_DATA_DIR=~/.local/share/autojump fi -if [ ! -e "${AUTOJUMP_DATA_DIR}" ] -then +if [ ! -e "${AUTOJUMP_DATA_DIR}" ]; then mkdir -p "${AUTOJUMP_DATA_DIR}" mv ~/.autojump_py "${AUTOJUMP_DATA_DIR}/autojump_py" 2>>/dev/null #migration mv ~/.autojump_py.bak "${AUTOJUMP_DATA_DIR}/autojump_py.bak" 2>>/dev/null mv ~/.autojump_errors "${AUTOJUMP_DATA_DIR}/autojump_errors" 2>>/dev/null fi +# set paths if necessary for local installations +if [ -d ~/.autojump/ ]; then + export PATH=~/.autojump/bin:"${PATH}" +fi + export AUTOJUMP_HOME=${HOME} AUTOJUMP='{ [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>"${AUTOJUMP_DATA_DIR}/.autojump_errors";} 2>/dev/null' diff --git a/autojump.sh b/autojump.sh index dab18b9..6f56b68 100644 --- a/autojump.sh +++ b/autojump.sh @@ -15,7 +15,15 @@ #You should have received a copy of the GNU General Public License #along with autojump. If not, see . if [ "$BASH_VERSION" ] && [ -n "$PS1" ] && echo $SHELLOPTS | grep -v posix >>/dev/null; then - . /etc/profile.d/autojump.bash + if [ -f ~/.autojump/etc/profile.d/autojump.bash ]; then + source ~/.autojump/etc/profile.d/autojump.bash + elif [ -f /etc/profile.d/autojump.bash ]; then + source /etc/profile.d/autojump.bash + fi elif [ "$ZSH_VERSION" ] && [ -n "$PS1" ]; then - . /etc/profile.d/autojump.zsh + if [ -f ~/.autojump/etc/profile.d/autojump.zsh ]; then + source ~/.autojump/etc/profile.d/autojump.zsh + elif [ -f /etc/profile.d/autojump.zsh ]; then + source /etc/profile.d/autojump.zsh + fi fi