Skip to content

zoxide doesn't expect PROMPT_COMMAND to be an array #1079

@mooreye

Description

@mooreye

New Bash versions prefer for PROMPT_COMMAND to be an array, for example:

PROMPT_COMMAND=(cmd1 cmd2 cmd3)

instead of legacy

PROMPT_COMMAND='cmd1; cmd2; cmd3'

However, zoxide always seems to do something like:

PROMPT_COMMAND="__zoxide_hook;$PROMPT_COMMAND"

which is fine because it works no matter if PROMPT_COMMAND is a regular variable or an array, but if it is an array, it results in an ugly array like so:

$ printf '%s\n' "${PROMPT_COMMAND[@]}"
__zoxide_hook;cmd1
cmd2
cmd3

I suggest detecting if PROMPT_COMMAND has more than 1 array element, and in that case do something like:

PROMPT_COMMAND=(__zoxide_hook "${PROMPT_COMMAND[@]}")

to prepend it to the array nicely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions