diff --git a/bin/autojump b/bin/autojump index 63f675b..f9eaf50 100755 --- a/bin/autojump +++ b/bin/autojump @@ -46,9 +46,10 @@ from autojump_data import Entry from autojump_data import load from autojump_data import save from autojump_utils import first -from autojump_utils import get_tab_entry_info from autojump_utils import get_pwd +from autojump_utils import get_tab_entry_info from autojump_utils import has_uppercase +from autojump_utils import is_autojump_sourced from autojump_utils import is_osx from autojump_utils import is_windows from autojump_utils import last @@ -59,7 +60,7 @@ from autojump_utils import sanitize from autojump_utils import take from autojump_utils import unico -VERSION = '22.1.0-beta' +VERSION = '22.1.1-beta' FUZZY_MATCH_THRESHOLD = 0.6 TAB_ENTRIES_COUNT = 9 TAB_SEPARATOR = '__' @@ -350,6 +351,12 @@ def print_stats(data, data_path): def main(args): # noqa + if not is_autojump_sourced() and not is_windows(): + print("Please source the correct autojump file in your shell's") + print("startup file. For more information, please reinstall autojump") + print("and read the post installation instructions.") + return 1 + config = set_defaults() # all arguments are mutually exclusive diff --git a/bin/autojump.bash b/bin/autojump.bash index 21fe9bf..774cb2b 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -1,3 +1,5 @@ +export AUTOJUMP_SOURCED=1 + # set user installation paths if [[ -d ~/.autojump/ ]]; then export PATH=~/.autojump/bin:"${PATH}" @@ -57,12 +59,13 @@ j() { return fi - new_path="$(autojump ${@})" - if [[ -d "${new_path}" ]]; then - echo -e "\\033[31m${new_path}\\033[0m" - cd "${new_path}" + output="$(autojump ${@})" + if [[ -d "${output}" ]]; then + echo -e "\\033[31m${output}\\033[0m" + cd "${output}" else echo "autojump: directory '${@}' not found" + echo "\n${output}\n" echo "Try \`autojump --help\` for more information." false fi @@ -86,17 +89,17 @@ jo() { return fi - new_path="$(autojump ${@})" - if [[ -d "${new_path}" ]]; then + output="$(autojump ${@})" + if [[ -d "${output}" ]]; then case ${OSTYPE} in linux-gnu) - xdg-open "${new_path}" + xdg-open "${output}" ;; darwin*) - open "${new_path}" + open "${output}" ;; cygwin) - cygstart "" $(cygpath -w -a ${new_path}) + cygstart "" $(cygpath -w -a ${output}) ;; *) echo "Unknown operating system." 1>&2 @@ -104,6 +107,7 @@ jo() { esac else echo "autojump: directory '${@}' not found" + echo "\n${output}\n" echo "Try \`autojump --help\` for more information." false fi diff --git a/bin/autojump.fish b/bin/autojump.fish index 98ced9b..f0dc153 100644 --- a/bin/autojump.fish +++ b/bin/autojump.fish @@ -1,3 +1,5 @@ +set -x AUTOJUMP_SOURCED 1 + # set user installation path if test -d ~/.autojump set -x PATH ~/.autojump/bin $PATH @@ -31,26 +33,22 @@ function __aj_err echo $argv 1>&2; false end -function __aj_not_found - __aj_err "autojump: directory '"$argv"' not found" - __aj_err "Try `autojump --help` for more information." -end - - # default autojump command function j switch "$argv" case '-*' '--*' autojump $argv case '*' - set -l new_path (autojump $argv) - if test -d "$new_path" + set -l output (autojump $argv) + if test -d "$output" set_color red - echo $new_path + echo $output set_color normal - cd $new_path + cd $output else - __aj_not_found $argv + __aj_err "autojump: directory '"$argv"' not found" + __aj_err "\n$output\n" + __aj_err "Try `autojump --help` for more information." end end end @@ -69,8 +67,11 @@ end # open autojump results in file browser function jo - if test -z (autojump $argv) - __aj_not_found $argv + set -l output (autojump $argv) + if test -d "$output" + __aj_err "autojump: directory '"$argv"' not found" + __aj_err "\n$output\n" + __aj_err "Try `autojump --help` for more information." else switch (sh -c 'echo ${OSTYPE}') case linux-gnu diff --git a/bin/autojump.zsh b/bin/autojump.zsh index 2b15787..3da3d76 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -1,3 +1,5 @@ +export AUTOJUMP_SOURCED=1 + # set user installation paths if [[ -d ~/.autojump/bin ]]; then path=(~/.autojump/bin ${path}) @@ -48,12 +50,13 @@ j() { fi setopt localoptions noautonamedirs - local new_path="$(autojump ${@})" - if [[ -d "${new_path}" ]]; then - echo -e "\\033[31m${new_path}\\033[0m" - cd "${new_path}" + local output="$(autojump ${@})" + if [[ -d "${output}" ]]; then + echo -e "\\033[31m${output}\\033[0m" + cd "${output}" else echo "autojump: directory '${@}' not found" + echo "\n${output}\n" echo "Try \`autojump --help\` for more information." false fi @@ -78,17 +81,17 @@ jo() { fi setopt localoptions noautonamedirs - local new_path="$(autojump ${@})" - if [[ -d "${new_path}" ]]; then + local output="$(autojump ${@})" + if [[ -d "${output}" ]]; then case ${OSTYPE} in linux-gnu) - xdg-open "${new_path}" + xdg-open "${output}" ;; darwin*) - open "${new_path}" + open "${output}" ;; cygwin) - cygstart "" $(cygpath -w -a ${new_path}) + cygstart "" $(cygpath -w -a ${output}) ;; *) echo "Unknown operating system." 1>&2 @@ -96,6 +99,7 @@ jo() { esac else echo "autojump: directory '${@}' not found" + echo "\n${output}\n" echo "Try \`autojump --help\` for more information." false fi diff --git a/bin/autojump_utils.py b/bin/autojump_utils.py index 9b9ece7..329e721 100644 --- a/bin/autojump_utils.py +++ b/bin/autojump_utils.py @@ -89,6 +89,10 @@ def in_bash(): return 'bash' in os.getenv('SHELL') +def is_autojump_sourced(): + return '1' == os.getenv('AUTOJUMP_SOURCED') + + def is_python2(): return sys.version_info[0] == 2 diff --git a/install.py b/install.py index 408e4c9..09fd557 100755 --- a/install.py +++ b/install.py @@ -136,7 +136,7 @@ def parse_arguments(): # noqa return args -def print_post_installation_message(etc_dir, share_dir, bin_dir): +def show_post_installation_message(etc_dir, share_dir, bin_dir): if platform.system() == 'Windows': print("\nPlease manually add %s to your user path" % bin_dir) else: @@ -209,7 +209,7 @@ def main(args): if args.custom_install: modify_autojump_sh(etc_dir, args.dryrun) - print_post_installation_message(etc_dir, share_dir, bin_dir) + show_post_installation_message(etc_dir, share_dir, bin_dir) if __name__ == "__main__":