From 77509f565a02781ea75592351e3876e535f71857 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sat, 11 Jul 2026 02:20:11 +0800 Subject: [PATCH] =?UTF-8?q?dot:=20=E9=87=8D=E6=9E=84=20bashrc.d=20?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=89=88=E6=9C=AC=EF=BC=88=E5=8C=85=EF=BC=89=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=99=A8=E8=84=9A=E6=9C=AC=E5=8A=A0=E8=BD=BD=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 mise、rust 等管理器脚本移入 manager/ 子目录,与工具脚本区分 - mise/volta 的补全改到各自 activate 函数内延迟生成,避免未激活时执行 - 新增 uv/uvx 的 bash 补全 - .bashrc 拆分为先加载 manager/ 再加载顶层脚本的两段流程 - .xprofile 改用 bash 解释并复用相同的脚本加载流程 --- dot/.bashrc | 8 +++++++- dot/.bashrc.d/{ => manager}/mise.bash | 9 ++++----- dot/.bashrc.d/{ => manager}/rust.bash | 2 +- dot/.bashrc.d/uv.bash | 12 +++++++++++ dot/.bashrc.d/volta.bash | 3 +-- dot/.xprofile | 29 ++++++++++++++++++--------- 6 files changed, 44 insertions(+), 19 deletions(-) rename dot/.bashrc.d/{ => manager}/mise.bash (71%) rename dot/.bashrc.d/{ => manager}/rust.bash (91%) create mode 100644 dot/.bashrc.d/uv.bash diff --git a/dot/.bashrc b/dot/.bashrc index 54cebf1..2e4a849 100644 --- a/dot/.bashrc +++ b/dot/.bashrc @@ -48,7 +48,7 @@ if [[ -n $(type -t _comp__split_longopt) ]] && [[ -z $(type -t _split_longopt) ] alias _split_longopt="_comp__split_longopt" fi -for _ in ${HOME}/.bashrc.d/*; do +for _ in ${HOME}/.bashrc.d/manager/*; do if [[ $_ == *.@(bash|sh) && -r $_ ]]; then source "$_" fi @@ -57,3 +57,9 @@ done if [[ -n "$(type -t mise-activate)" ]]; then mise-activate fi + +for _ in ${HOME}/.bashrc.d/*; do + if [[ $_ == *.@(bash|sh) && -r $_ ]]; then + source "$_" + fi +done diff --git a/dot/.bashrc.d/mise.bash b/dot/.bashrc.d/manager/mise.bash similarity index 71% rename from dot/.bashrc.d/mise.bash rename to dot/.bashrc.d/manager/mise.bash index 1bceb9d..2431341 100644 --- a/dot/.bashrc.d/mise.bash +++ b/dot/.bashrc.d/manager/mise.bash @@ -1,15 +1,14 @@ basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}")) -source "${basedir}/function.bash" +source "${basedir}/../function.bash" unset basedir 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() { eval "$(mise activate bash)" + + local completion_cmd="mise completion --include-bash-completion-lib bash" + generate-bash-completion mise "$completion_cmd" } mise-deactivate() { diff --git a/dot/.bashrc.d/rust.bash b/dot/.bashrc.d/manager/rust.bash similarity index 91% rename from dot/.bashrc.d/rust.bash rename to dot/.bashrc.d/manager/rust.bash index bda869e..730ce0d 100644 --- a/dot/.bashrc.d/rust.bash +++ b/dot/.bashrc.d/manager/rust.bash @@ -1,5 +1,5 @@ basedir=$(realpath -m $(dirname "${BASH_SOURCE[0]:-$0}")) -source "${basedir}/function.bash" +source "${basedir}/../function.bash" unset basedir diff --git a/dot/.bashrc.d/uv.bash b/dot/.bashrc.d/uv.bash new file mode 100644 index 0000000..138b13c --- /dev/null +++ b/dot/.bashrc.d/uv.bash @@ -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 diff --git a/dot/.bashrc.d/volta.bash b/dot/.bashrc.d/volta.bash index a0b2628..2716380 100644 --- a/dot/.bashrc.d/volta.bash +++ b/dot/.bashrc.d/volta.bash @@ -6,10 +6,9 @@ unset basedir export VOLTA_HOME="${HOME}/.volta" if [[ -x $(type -p volta) || -x "${VOLTA_HOME}/bin/volta" ]]; then - generate-bash-completion volta "volta completions bash" - volta-activate() { add-to-path "${VOLTA_HOME}/bin" + generate-bash-completion volta "volta completions bash" # enable pnpm support # export VOLTA_FEATURE_PNPM=1 diff --git a/dot/.xprofile b/dot/.xprofile index 605420f..7e9d4bd 100644 --- a/dot/.xprofile +++ b/dot/.xprofile @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/bash #xrandr --output HDMI-1 --same-as LVDS-1 @@ -38,14 +38,23 @@ fcitx5 -d #sudo service shadowsocks.client start # emacs --daemon -export PATH="~/.local/bin${PATH:+:}$PATH" -# pnpm -export PATH="~/.local/share/pnpm${PATH:+:}$PATH" -# pnpm end +# shell environment setup +export PATH="${HOME}/.local/bin${PATH:+:}$PATH" -# rust cargo -export PATH="~/.cargo/bin${PATH:+:}$PATH" -if [[ -e "$HOME/.cargo/env" ]]; then - . "$HOME/.cargo/env" +for _ in ${HOME}/.bashrc.d/manager/*; do + if [[ $_ == *.@(bash|sh) && -r $_ ]]; then + echo "$_" + source "$_" + fi +done + +if [[ -n "$(type -t mise-activate)" ]]; then + mise-activate fi -# rust cargo end + +for _ in ${HOME}/.bashrc.d/*; do + echo "$_" + if [[ $_ == *.@(bash|sh) && -r $_ ]]; then + source "$_" + fi +done