Skip to content

Commit 5fde313

Browse files
Don't downcast PROMPT_COMMAND (#1036)
1 parent af220b1 commit 5fde313

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

templates/bash.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ function __zoxide_hook() {
5555

5656
# Initialize hook.
5757
if [[ ${PROMPT_COMMAND:=} != *'__zoxide_hook'* ]]; then
58-
PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND#;}"
58+
if [[ "$(declare -p PROMPT_COMMAND 2>&1)" == "declare -a"* ]]; then
59+
PROMPT_COMMAND=(__zoxide_hook "${PROMPT_COMMAND[@]}")
60+
else
61+
# shellcheck disable=SC2178
62+
PROMPT_COMMAND="__zoxide_hook;${PROMPT_COMMAND#;}"
63+
fi
5964
fi
6065

6166
{%- endif %}

0 commit comments

Comments
 (0)