From f480bd131576da5933b58dd4434bb79684da82ef Mon Sep 17 00:00:00 2001 From: William Ting Date: Sat, 4 Oct 2014 20:27:51 -0700 Subject: [PATCH] Detect user shell as opposed to login shell. Fixes #256. --- bin/autojump | 2 +- bin/autojump.sh | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bin/autojump b/bin/autojump index 54f996a..5a39a75 100755 --- a/bin/autojump +++ b/bin/autojump @@ -59,7 +59,7 @@ from autojump_utils import sanitize from autojump_utils import take from autojump_utils import unico -VERSION = '22.0.1-beta' +VERSION = '22.0.2-beta' FUZZY_MATCH_THRESHOLD = 0.6 TAB_ENTRIES_COUNT = 9 TAB_SEPARATOR = '__' diff --git a/bin/autojump.sh b/bin/autojump.sh index 1d19202..8b7ec0f 100644 --- a/bin/autojump.sh +++ b/bin/autojump.sh @@ -1,6 +1,16 @@ -# source autojump on BASH or ZSH depending on the shell - -shell=$(echo ${SHELL} | awk -F/ '{ print $NF }') +# the login $SHELL isn't always the one used +# NOTE: problems might occur if /bin/sh is symlinked to /bin/bash +if [ -n "${BASH}" ]; then + shell="bash" +elif [ -n "${ZSH_NAME}" ]; then + shell="zsh" +elif [ -n "${__fish_datadir}" ]; then + shell="fish" +elif [ -n "${version}" ]; then + shell="tcsh" +else + shell=$(echo ${SHELL} | awk -F/ '{ print $NF }') +fi # prevent circular loop for sh shells if [ "${shell}" = "sh" ]; then