dot: 重构 bashrc.d 目录结构,调整版本(包)管理器脚本加载顺序

- 将 mise、rust 等管理器脚本移入 manager/ 子目录,与工具脚本区分
- mise/volta 的补全改到各自 activate 函数内延迟生成,避免未激活时执行
- 新增 uv/uvx 的 bash 补全
- .bashrc 拆分为先加载 manager/ 再加载顶层脚本的两段流程
- .xprofile 改用 bash 解释并复用相同的脚本加载流程
This commit is contained in:
2026-07-11 02:20:11 +08:00
parent 1a6fa5c1a3
commit 77509f565a
6 changed files with 44 additions and 19 deletions

View File

@@ -48,7 +48,7 @@ if [[ -n $(type -t _comp__split_longopt) ]] && [[ -z $(type -t _split_longopt) ]
alias _split_longopt="_comp__split_longopt" alias _split_longopt="_comp__split_longopt"
fi fi
for _ in ${HOME}/.bashrc.d/*; do for _ in ${HOME}/.bashrc.d/manager/*; do
if [[ $_ == *.@(bash|sh) && -r $_ ]]; then if [[ $_ == *.@(bash|sh) && -r $_ ]]; then
source "$_" source "$_"
fi fi
@@ -57,3 +57,9 @@ done
if [[ -n "$(type -t mise-activate)" ]]; then if [[ -n "$(type -t mise-activate)" ]]; then
mise-activate mise-activate
fi fi
for _ in ${HOME}/.bashrc.d/*; do
if [[ $_ == *.@(bash|sh) && -r $_ ]]; then
source "$_"
fi
done

View File

@@ -1,15 +1,14 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}")) basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash" source "${basedir}/../function.bash"
unset basedir unset basedir
if [[ -x $(type -p mise) ]]; then if [[ -x $(type -p mise) ]]; then
completion_cmd="mise completion --include-bash-completion-lib bash"
generate-bash-completion mise "$completion_cmd"
unset completion_cmd
mise-activate() { mise-activate() {
eval "$(mise activate bash)" eval "$(mise activate bash)"
local completion_cmd="mise completion --include-bash-completion-lib bash"
generate-bash-completion mise "$completion_cmd"
} }
mise-deactivate() { mise-deactivate() {

View File

@@ -1,5 +1,5 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}")) basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash" source "${basedir}/../function.bash"
unset basedir unset basedir

12
dot/.bashrc.d/uv.bash Normal file
View File

@@ -0,0 +1,12 @@
basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}"))
source "${basedir}/function.bash"
unset basedir
if [[ -x "$(type -p uv)" ]]; then
generate-bash-completion uv "uv generate-shell-completion bash"
fi
if [[ -x "$(type -p uvx)" ]]; then
generate-bash-completion uvx "uvx --generate-shell-completion bash"
fi

View File

@@ -6,10 +6,9 @@ unset basedir
export VOLTA_HOME="${HOME}/.volta" export VOLTA_HOME="${HOME}/.volta"
if [[ -x $(type -p volta) || -x "${VOLTA_HOME}/bin/volta" ]]; then if [[ -x $(type -p volta) || -x "${VOLTA_HOME}/bin/volta" ]]; then
generate-bash-completion volta "volta completions bash"
volta-activate() { volta-activate() {
add-to-path "${VOLTA_HOME}/bin" add-to-path "${VOLTA_HOME}/bin"
generate-bash-completion volta "volta completions bash"
# enable pnpm support # enable pnpm support
# export VOLTA_FEATURE_PNPM=1 # export VOLTA_FEATURE_PNPM=1

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/bin/bash
#xrandr --output HDMI-1 --same-as LVDS-1 #xrandr --output HDMI-1 --same-as LVDS-1
@@ -38,14 +38,23 @@ fcitx5 -d
#sudo service shadowsocks.client start #sudo service shadowsocks.client start
# emacs --daemon # emacs --daemon
export PATH="~/.local/bin${PATH:+:}$PATH" # shell environment setup
# pnpm export PATH="${HOME}/.local/bin${PATH:+:}$PATH"
export PATH="~/.local/share/pnpm${PATH:+:}$PATH"
# pnpm end
# rust cargo for _ in ${HOME}/.bashrc.d/manager/*; do
export PATH="~/.cargo/bin${PATH:+:}$PATH" if [[ $_ == *.@(bash|sh) && -r $_ ]]; then
if [[ -e "$HOME/.cargo/env" ]]; then echo "$_"
. "$HOME/.cargo/env" source "$_"
fi
done
if [[ -n "$(type -t mise-activate)" ]]; then
mise-activate
fi fi
# rust cargo end
for _ in ${HOME}/.bashrc.d/*; do
echo "$_"
if [[ $_ == *.@(bash|sh) && -r $_ ]]; then
source "$_"
fi
done