Skip to content

Commit c770a05

Browse files
committed
bash doctor
1 parent 791deec commit c770a05

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

templates/bash.txt

+26-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,28 @@ fi
6262

6363
{% endif -%}
6464

65+
# Report common issues.
66+
function __zoxide_doctor() {
67+
{%- if hook == InitHook::None %}
68+
return 0
69+
70+
{%- else %}
71+
[[ ${_ZO_DOCTOR:-1} -ne 0 ]] || return 0
72+
[[ ${PROMPT_COMMAND:=} != *'__zoxide_hook'* ]] || return 0
73+
74+
_ZO_DOCTOR=0
75+
\builtin printf '%s\n' \
76+
'zoxide: detected a possible configuration issue.' \
77+
'Please ensure that zoxide is initialized right at the end of your shell configuration file (usually ~/.bashrc).' \
78+
'' \
79+
'If the issue persists, consider filing an issue at:' \
80+
'https://github.com/ajeetdsouza/zoxide/issues' \
81+
'' \
82+
'Disable this message by setting _ZO_DOCTOR=0.' \
83+
'' >&2
84+
{%- endif %}
85+
}
86+
6587
{{ section }}
6688
# When using zoxide with --no-cmd, alias these internal functions as desired.
6789
#
@@ -70,6 +92,8 @@ __zoxide_z_prefix='z#'
7092

7193
# Jump to a directory using only keywords.
7294
function __zoxide_z() {
95+
__zoxide_doctor
96+
7397
# shellcheck disable=SC2199
7498
if [[ $# -eq 0 ]]; then
7599
__zoxide_cd ~
@@ -93,6 +117,7 @@ function __zoxide_z() {
93117

94118
# Jump to a directory using interactive search.
95119
function __zoxide_zi() {
120+
__zoxide_doctor
96121
\builtin local result
97122
result="$(\command zoxide query --interactive -- "$@")" && __zoxide_cd "${result}"
98123
}
@@ -154,6 +179,6 @@ fi
154179
{%- endmatch %}
155180

156181
{{ section }}
157-
# To initialize zoxide, add this to your configuration (usually ~/.bashrc):
182+
# To initialize zoxide, add this to your shell configuration file (usually ~/.bashrc):
158183
#
159184
# eval "$(zoxide init bash)"

templates/zsh.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function __zoxide_doctor() {
6969
'Please ensure that zoxide is initialized right at the end of your shell configuration file (usually ~/.zshrc).' \
7070
'' \
7171
'If the issue persists, consider filing an issue at:' \
72-
'https://github.com/ajeetdsouza/zoxide/issues.' \
72+
'https://github.com/ajeetdsouza/zoxide/issues' \
7373
'' \
7474
'Disable this message by setting _ZO_DOCTOR=0.' \
7575
'' >&2

0 commit comments

Comments
 (0)