@@ -27,11 +27,8 @@ function __zoxide_cd() {
27
27
{{ section }}
28
28
# Hook configuration for zoxide.
29
29
#
30
+ {%- if hook != InitHook::None %}
30
31
31
- {% if hook == InitHook::None -%}
32
- {{ not_configured }}
33
-
34
- {%- else -%}
35
32
# Hook to add new entries to the database.
36
33
{%- if hook == InitHook::Prompt %}
37
34
function __zoxide_hook() {
@@ -40,6 +37,7 @@ function __zoxide_hook() {
40
37
\command zoxide add -- "$(__zoxide_pwd)"
41
38
return "${retval}"
42
39
}
40
+
43
41
{%- else if hook == InitHook::Pwd %}
44
42
__zoxide_oldpwd="$(__zoxide_pwd)"
45
43
@@ -60,7 +58,29 @@ if [[ ${PROMPT_COMMAND:=} != *'__zoxide_hook'* ]]; then
60
58
PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND#;}"
61
59
fi
62
60
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
+ }
64
84
65
85
{{ section }}
66
86
# When using zoxide with --no-cmd, alias these internal functions as desired.
@@ -70,6 +90,8 @@ __zoxide_z_prefix='z#'
70
90
71
91
# Jump to a directory using only keywords.
72
92
function __zoxide_z() {
93
+ __zoxide_doctor
94
+
73
95
# shellcheck disable=SC2199
74
96
if [[ $# -eq 0 ]]; then
75
97
__zoxide_cd ~
@@ -93,6 +115,7 @@ function __zoxide_z() {
93
115
94
116
# Jump to a directory using interactive search.
95
117
function __zoxide_zi() {
118
+ __zoxide_doctor
96
119
\builtin local result
97
120
result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}"
98
121
}
154
177
{%- endmatch %}
155
178
156
179
{{ 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):
158
181
#
159
182
# eval "$(zoxide init bash)"
0 commit comments