84b5ed4412
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
83 lines
3.4 KiB
Bash
83 lines
3.4 KiB
Bash
# opencode-devbox bash aliases and customizations
|
|
# Sourced by the Debian-default ~/.bashrc on shell startup.
|
|
# To override, bind-mount your host's ~/.bash_aliases over this file
|
|
# via docker-compose.yml.
|
|
|
|
# ── History persistence and quality ──────────────────────────────────
|
|
# The named volume devbox-shell-history is mounted at ~/.cache/bash
|
|
# so history survives container recreation.
|
|
export HISTFILE="${HOME}/.cache/bash/history"
|
|
mkdir -p "$(dirname "$HISTFILE")" 2>/dev/null || true
|
|
|
|
# Large, time-stamped, deduplicated history. Append rather than overwrite.
|
|
export HISTSIZE=100000
|
|
export HISTFILESIZE=200000
|
|
export HISTCONTROL=ignoreboth:erasedups
|
|
export HISTTIMEFORMAT='%F %T '
|
|
shopt -s histappend 2>/dev/null
|
|
shopt -s cmdhist 2>/dev/null
|
|
# Note: PROMPT_COMMAND="history -a" is installed LATER in this file,
|
|
# after zoxide's init runs. Installing it here would create a
|
|
# "history -a;;__zoxide_hook" chain because zoxide's init uses ';'
|
|
# as its separator and prepends itself; two adjacent ';' breaks the
|
|
# parser. See https://github.com/ajeetdsouza/zoxide/issues/722.
|
|
|
|
# ── Common aliases ───────────────────────────────────────────────────
|
|
# Prefer eza (modern ls) when available
|
|
if command -v eza >/dev/null 2>&1; then
|
|
alias ls='eza --group-directories-first'
|
|
alias ll='eza -lh --group-directories-first --git'
|
|
alias la='eza -lha --group-directories-first --git'
|
|
alias tree='eza --tree'
|
|
else
|
|
alias ll='ls -lh'
|
|
alias la='ls -lha'
|
|
fi
|
|
|
|
# Prefer bat (syntax-highlighted cat) when available
|
|
if command -v bat >/dev/null 2>&1; then
|
|
alias cat='bat --style=plain --paging=never'
|
|
alias less='bat --paging=always'
|
|
fi
|
|
|
|
# Git shortcuts
|
|
alias gs='git status'
|
|
alias gd='git diff'
|
|
alias gl='git log --oneline --graph --decorate -20'
|
|
|
|
# Safety: confirm before destructive ops
|
|
alias rm='rm -i'
|
|
alias mv='mv -i'
|
|
alias cp='cp -i'
|
|
|
|
# ── Shell integrations ───────────────────────────────────────────────
|
|
# zoxide — smarter cd. Use 'z <fragment>' to jump to previously-visited dirs.
|
|
if command -v zoxide >/dev/null 2>&1; then
|
|
eval "$(zoxide init bash)"
|
|
fi
|
|
|
|
# fzf — fuzzy finder key bindings (Ctrl-R for history, Ctrl-T for files).
|
|
# We install fzf from GitHub releases (not apt), so sourcing from the
|
|
# apt-path /usr/share/doc/fzf/examples/* would find nothing. Use the
|
|
# binary's own --bash flag (available since fzf 0.48) for setup.
|
|
if command -v fzf >/dev/null 2>&1; then
|
|
eval "$(fzf --bash)" 2>/dev/null || true
|
|
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
|
|
# Preserves the default Debian PS1 logic but prefixes with a container marker.
|
|
if [ -n "${PS1:-}" ] && [ -z "${DEVBOX_PS1_SET:-}" ]; then
|
|
PS1='\[\e[38;5;39m\][devbox]\[\e[0m\] '"${PS1}"
|
|
export DEVBOX_PS1_SET=1
|
|
fi
|