Fix PROMPT_COMMAND collision with zoxide causing ';;' parse error
v1.14.19c installed 'history -a; ' at the start of PROMPT_COMMAND
before zoxide's init ran. Zoxide's init uses ';' as its separator
when prepending __zoxide_hook, producing 'history -a;;__zoxide_hook'.
Every interactive prompt then emitted:
bash: PROMPT_COMMAND: syntax error near unexpected token ';;'
History flushing still worked (the 'history -a' half parsed fine),
but the error spam made the shell feel broken.
Fix by moving the history-flush PROMPT_COMMAND assignment AFTER
zoxide's init, and using a newline separator (via ${PROMPT_COMMAND:+...}
parameter expansion) so there's no semicolon involved at all. Each
PROMPT_COMMAND line runs as its own statement, no parsing contention.
Known upstream issue: https://github.com/ajeetdsouza/zoxide/issues/722
This commit is contained in:
@@ -16,12 +16,11 @@ export HISTCONTROL=ignoreboth:erasedups
|
|||||||
export HISTTIMEFORMAT='%F %T '
|
export HISTTIMEFORMAT='%F %T '
|
||||||
shopt -s histappend 2>/dev/null
|
shopt -s histappend 2>/dev/null
|
||||||
shopt -s cmdhist 2>/dev/null
|
shopt -s cmdhist 2>/dev/null
|
||||||
# Flush every command to disk immediately so reboots don't lose recent work.
|
# Note: PROMPT_COMMAND="history -a" is installed LATER in this file,
|
||||||
# Guarded so repeated sourcing (e.g. `exec bash`) doesn't stack duplicates.
|
# after zoxide's init runs. Installing it here would create a
|
||||||
if [ -z "${DEVBOX_HIST_SET:-}" ]; then
|
# "history -a;;__zoxide_hook" chain because zoxide's init uses ';'
|
||||||
PROMPT_COMMAND="history -a; ${PROMPT_COMMAND:-}"
|
# as its separator and prepends itself; two adjacent ';' breaks the
|
||||||
export DEVBOX_HIST_SET=1
|
# parser. See https://github.com/ajeetdsouza/zoxide/issues/722.
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Common aliases ───────────────────────────────────────────────────
|
# ── Common aliases ───────────────────────────────────────────────────
|
||||||
# Prefer eza (modern ls) when available
|
# Prefer eza (modern ls) when available
|
||||||
@@ -65,6 +64,16 @@ if command -v fzf >/dev/null 2>&1; then
|
|||||||
eval "$(fzf --bash)" 2>/dev/null || true
|
eval "$(fzf --bash)" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ── PROMPT_COMMAND: flush history every prompt ───────────────────────
|
||||||
|
# Installed AFTER zoxide init so zoxide's hook is already in place;
|
||||||
|
# we append with a newline separator to avoid the ';;' parse error
|
||||||
|
# described at the top of this file. Guarded so repeated sourcing
|
||||||
|
# (e.g. `exec bash`) doesn't stack duplicates.
|
||||||
|
if [ -z "${DEVBOX_HIST_SET:-}" ]; then
|
||||||
|
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a"
|
||||||
|
export DEVBOX_HIST_SET=1
|
||||||
|
fi
|
||||||
|
|
||||||
# ── Prompt: show [opencode-devbox] tag so it's obvious you're in the container
|
# ── Prompt: show [opencode-devbox] tag so it's obvious you're in the container
|
||||||
# Preserves the default Debian PS1 logic but prefixes with a container marker.
|
# Preserves the default Debian PS1 logic but prefixes with a container marker.
|
||||||
if [ -n "${PS1:-}" ] && [ -z "${DEVBOX_PS1_SET:-}" ]; then
|
if [ -n "${PS1:-}" ] && [ -z "${DEVBOX_PS1_SET:-}" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user