From: Xinqi Bao Date: Mon, 19 Oct 2026 15:09:45 +0000 (+0800) Subject: fix(bash): correct shell initialization X-Git-Url: https://git.xinqibao.xyz/dotfiles.git/commitdiff_plain/bcf6c79daee82fac1b00ea8357967d4e0fcb23d2?ds=sidebyside;hp=99a8469909a5da2557fa0c48216b3ae5556570e1 fix(bash): correct shell initialization Preserve the inherited TERM and load Cargo paths before activating mise. Correct ls aliases, query Git branch names directly with a detached HEAD fallback, and use the environment's browser selection. Avoid numeric comparisons with unset display variables and leave Wayland sessions intact. Keep local PATH entries separate. --- diff --git a/.bashrc b/.bashrc index 6e01dbc..be35211 100644 --- a/.bashrc +++ b/.bashrc @@ -5,20 +5,24 @@ # If not running interactively, don't do anything [[ $- != *i* ]] && return -export PATH=${HOME}/.local/opt/node/bin:${PATH} -export PATH=${HOME}/.local/bin:${PATH} -export PATH=${HOME}/tool:${PATH} +export PATH="${HOME}/.local/opt/node/bin:${PATH}" +export PATH="${HOME}/.local/bin:${PATH}" +export PATH="${HOME}/tool:${PATH}" + +# Let mise take precedence over Cargo and local tools. +[ -f "${HOME}/.cargo/env" ] && . "${HOME}/.cargo/env" +if command -v mise >/dev/null 2>&1; then + eval "$(mise activate bash)" +fi + +alias ls='ls --color=auto' +alias ll='ls -lhrt' -alias ls='ls --color=auto -G' -alias ll='ls --color=auto -G -lhrt' alias vim='nvim' alias vimdiff='nvim -d' - export EDITOR=nvim -export BROWSER=firefox -export PS1="[\[\e[36;1m\]\u@\h \[\e[32;1m\]\w\[\e[m\]]\[\e[33m\](\$(git branch 2>/dev/null | grep '^*' | colrm 1 2))\n\[\e[m\]~~~>\$ " -export TERM=xterm-256color +PS1='[\[\e[36;1m\]\u@\h \[\e[32;1m\]\w\[\e[m\]]\[\e[33m\]($(git symbolic-ref --quiet --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))\n\[\e[m\]~~~>\$ ' ulimit -c unlimited @@ -28,16 +32,10 @@ ulimit -c unlimited #export HTTP_PROXY=$proxy_url #export HTTPS_PROXY=$proxy_url -if command -v mise >/dev/null 2>&1; then - eval "$(mise activate bash)" -fi - -# Set up fzf key bindings and fuzzy completion +# fzf key bindings and completion eval "$(fzf --bash)" export FZF_CTRL_T_OPTS="--preview 'bat --style=numbers --color=always --line-range :500 {}'" -[ -f ${HOME}/.cargo/env ] && . ${HOME}/.cargo/env - -if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then +if [[ -z ${DISPLAY:-} && -z ${WAYLAND_DISPLAY:-} && ${XDG_VTNR:-} == 1 ]]; then exec startx fi