@@ -27,11 +27,8 @@ function __zoxide_cd() {
2727{{ section }}
2828# Hook configuration for zoxide.
2929#
30+ {%- if hook != InitHook::None %}
3031
31- {% if hook == InitHook::None -%}
32- {{ not_configured }}
33-
34- {%- else -%}
3532# Hook to add new entries to the database.
3633{%- if hook == InitHook::Prompt %}
3734function __zoxide_hook() {
@@ -40,6 +37,7 @@ function __zoxide_hook() {
4037 \command zoxide add -- "$(__zoxide_pwd)"
4138 return "${retval}"
4239}
40+
4341{%- else if hook == InitHook::Pwd %}
4442__zoxide_oldpwd="$(__zoxide_pwd)"
4543
@@ -60,7 +58,29 @@ if [[ ${PROMPT_COMMAND:=} != *'__zoxide_hook'* ]]; then
6058 PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND#;}"
6159fi
6260
63- {% endif -%}
61+ {%- endif %}
62+
63+ # Report common issues.
64+ function __zoxide_doctor() {
65+ {%- if hook == InitHook::None %}
66+ return 0
67+
68+ {%- else %}
69+ [[ ${_ZO_DOCTOR:-1} -ne 0 ]] || return 0
70+ [[ ${PROMPT_COMMAND:=} != *'__zoxide_hook'* ]] || return 0
71+
72+ _ZO_DOCTOR=0
73+ \builtin printf '%s\n' \
74+ 'zoxide: detected a possible configuration issue.' \
75+ 'Please ensure that zoxide is initialized right at the end of your shell configuration file (usually ~/.bashrc).' \
76+ '' \
77+ 'If the issue persists, consider filing an issue at:' \
78+ 'https://github.com/ajeetdsouza/zoxide/issues' \
79+ '' \
80+ 'Disable this message by setting _ZO_DOCTOR=0.' \
81+ '' >&2
82+ {%- endif %}
83+ }
6484
6585{{ section }}
6686# When using zoxide with --no-cmd, alias these internal functions as desired.
@@ -70,6 +90,8 @@ __zoxide_z_prefix='z#'
7090
7191# Jump to a directory using only keywords.
7292function __zoxide_z() {
93+ __zoxide_doctor
94+
7395 # shellcheck disable=SC2199
7496 if [[ $# -eq 0 ]]; then
7597 __zoxide_cd ~
@@ -93,6 +115,7 @@ function __zoxide_z() {
93115
94116# Jump to a directory using interactive search.
95117function __zoxide_zi() {
118+ __zoxide_doctor
96119 \builtin local result
97120 result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}"
98121}
154177{%- endmatch %}
155178
156179{{ section }}
157- # To initialize zoxide, add this to your configuration (usually ~/.bashrc):
180+ # To initialize zoxide, add this to your shell configuration file (usually ~/.bashrc):
158181#
159182# eval "$(zoxide init bash)"
0 commit comments