Compare commits

..

3 Commits

7 changed files with 133 additions and 138 deletions
+3 -3
View File
@@ -18,7 +18,7 @@
│ ├── dev.py # 开发模块(语言运行时 + LSP + 工具链)
│ ├── docker.py # Docker 模块(packages + systemd units
│ ├── locale.py # locale 模块(on_change hook 示例)
│ └── zsh.py # Zsh 模块(shell + 插件 + 自动 chsh
│ └── fish.py # Fish 模块(shell + fzf + 自动 chsh
├── system/etc/ # 系统配置文件源 → /etc/
├── home/ # 用户配置文件源 → ~/(必须指定 owner)
├── scripts/
@@ -101,7 +101,7 @@ class DockerModule(Module):
return {"docker.socket"}
```
**模块组织原则**:所有 files / packages / units 声明都通过 Module 封装,按领域拆分(base / dev / docker / locale / zsh)。新增功能优先加到对应现有模块;跨领域、需要 lifecycle hook(`on_change` / `after_update`)或需要绑定 packages + systemd units 时再新建模块。
**模块组织原则**:所有 files / packages / units 声明都通过 Module 封装,按领域拆分(base / dev / docker / locale / fish)。新增功能优先加到对应现有模块;跨领域、需要 lifecycle hook(`on_change` / `after_update`)或需要绑定 packages + systemd units 时再新建模块。
### Shell 脚本
@@ -123,7 +123,7 @@ class DockerModule(Module):
## 关键依赖关系
`.zshrc` 别名与包的绑定(修改前务必检查):
`.config/fish/config.fish` 别名与包的绑定(修改前务必检查):
| 别名 | 依赖包 | 位置 |
|------|--------|------|
+89
View File
@@ -0,0 +1,89 @@
fish_add_path "$HOME/go/bin" "$HOME/.bun/bin"
set -gx EDITOR nvim
set -gx VISUAL nvim
set -gx PAGER less
set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'"
set -g fish_greeting
function __prepend_sudo
set -l buffer (commandline)
if test -z "$buffer"
commandline -f up-line
set buffer (commandline)
end
if test -n "$buffer"
if not string match -qr '^sudo\b' -- "$buffer"
commandline -r "sudo $buffer"
end
commandline -f end-of-line repaint
end
end
bind \e\e __prepend_sudo
bind \c@ accept-autosuggestion
set -gx FZF_DEFAULT_OPTS '--height=50% --layout=reverse --border --preview-window=right:60%'
set -gx FZF_DEFAULT_COMMAND 'fd --type f --hidden --follow --exclude .git'
set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND"
set -gx FZF_ALT_C_COMMAND 'fd --type d --hidden --follow --exclude .git'
alias ..='cd ..'
alias ...='cd ../..'
function ls
command eza --icons --group-directories-first --git $argv
end
function l
command eza -la --icons --group-directories-first --git $argv
end
function ll
command eza -l --icons --group-directories-first --git $argv
end
function la
command eza -lA --icons --group-directories-first --git $argv
end
function lt
command eza --tree --level=2 --icons --group-directories-first --git $argv
end
alias cat='bat --paging=never'
alias rm='gomi'
alias lg='lazygit'
alias vi='nvim'
alias x='ouch decompress'
if set -q WSL_DISTRO_NAME
alias pbcopy='clip.exe'
alias pbpaste='powershell.exe -noprofile -c Get-Clipboard'
function keep_current_path --on-event fish_prompt
printf '\e]9;9;%s\e\\' (wslpath -w "$PWD")
end
end
if status is-interactive
zoxide init fish --cmd cd | source
mise activate fish | source
set -g direnv_fish_mode eval_after_arrow
direnv hook fish | source
fzf --fish | source
set -gx ATUIN_NOBIND true
atuin init fish | source
bind \cr _atuin_search
starship init fish | source
end
if test -f ~/.config/fish/config.local.fish
source ~/.config/fish/config.local.fish
end
+12
View File
@@ -0,0 +1,12 @@
function yy
set -l tmp (mktemp -t yazi-cwd.XXXXXX)
command yazi $argv --cwd-file="$tmp"
if set -l cwd (command cat -- "$tmp")
if test -n "$cwd" -a "$cwd" != "$PWD"
builtin cd -- "$cwd"
end
end
command rm -f -- "$tmp"
end
-102
View File
@@ -1,102 +0,0 @@
# ── PATH ──
export PATH="$HOME/go/bin:$HOME/.bun/bin:$PATH"
# ── 默认编辑器与分页器 ──
export EDITOR=nvim
export VISUAL=nvim
export PAGER=less
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
# ── Shell 选项 ──
setopt AUTO_CD # 输目录名直接 cd
setopt INTERACTIVE_COMMENTS # 允许交互式 # 注释
setopt NO_BEEP # 关蜂鸣
# ── 补全系统(必须在 fzf-tab 之前)──
# 每天重建一次 zcompdump,其余启动直接复用,节省启动时间
autoload -Uz compinit
if [[ -n ~/.zcompdump(#qN.mh+24) ]]; then
compinit
else
compinit -C
fi
# 保留大小写敏感优先,找不到时再回退到大小写不敏感补全
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
# ── 外部插件 ──
source /usr/share/zsh/plugins/fzf-tab-git/fzf-tab.plugin.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # 必须最后
# ── 双击 ESC 自动加 sudo ──
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
zle end-of-line
}
zle -N sudo-command-line
bindkey '\e\e' sudo-command-line
# ── Ctrl+Space 接受自动建议 ──
bindkey '^ ' autosuggest-accept
# ── FZF 默认行为(fd 联动 + 现代 UI)──
export FZF_DEFAULT_OPTS='--height=50% --layout=reverse --border --preview-window=right:60%'
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'
# ── 工具初始化(顺序重要)──
eval "$(starship init zsh)"
eval "$(zoxide init --cmd cd zsh)" # cd 直接被 zoxide 接管,cdi 自动可用
eval "$(mise activate zsh)"
eval "$(direnv hook zsh)"
eval "$(fzf --zsh)" # Ctrl+T 搜文件, Alt+C 搜目录
eval "$(atuin init zsh)" # 必须在 fzf 之后,接管 Ctrl+R
# ── 别名 ──
# 导航
alias ..="cd .."
alias ...="cd ../.."
# 文件列表(公共参数提取,DRY
_EZA_BASE=(--icons --group-directories-first --git)
alias ls="eza ${_EZA_BASE}"
alias l="eza -la ${_EZA_BASE}"
alias ll="eza -l ${_EZA_BASE}"
alias la="eza -lA ${_EZA_BASE}"
alias lt="eza --tree --level=2 ${_EZA_BASE}"
# 工具
alias cat="bat --paging=never"
alias rm="gomi"
alias lg="lazygit"
alias vi="nvim"
alias x="ouch decompress" # 万能解压(zip/tar/gz/bz2/xz/zst/7z/rar
# ── yazi wrapper:退出时自动 cd 到最后目录 ──
function yy() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [[ -n "$cwd" && "$cwd" != "$PWD" ]]; then
builtin cd -- "$cwd"
fi
command rm -f -- "$tmp"
}
# ── WSL 集成 ──
if [[ -n "$WSL_DISTRO_NAME" ]]; then
# 剪贴板互通
alias pbcopy="clip.exe"
alias pbpaste="powershell.exe -noprofile -c Get-Clipboard"
# Windows Terminal: 新标签/窗格继承当前目录(OSC 9;9 序列)
keep_current_path() {
printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"
}
precmd_functions+=(keep_current_path)
fi
# ── Local ──
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
+12 -19
View File
@@ -2,19 +2,22 @@ import subprocess
import decman
from decman import File, Module
from decman.plugins.aur import packages as aur_packages
from decman.plugins.pacman import packages as pacman_packages
class ZshModule(Module):
class FishModule(Module):
def __init__(self, user: str):
super().__init__("zsh")
super().__init__("fish")
self.user = user
def files(self) -> dict[str, File]:
return {
f"/home/{self.user}/.zshrc": File(
source_file="./home/.zshrc",
f"/home/{self.user}/.config/fish/config.fish": File(
source_file="./home/.config/fish/config.fish",
owner=self.user,
),
f"/home/{self.user}/.config/fish/functions/yy.fish": File(
source_file="./home/.config/fish/functions/yy.fish",
owner=self.user,
),
}
@@ -22,17 +25,8 @@ class ZshModule(Module):
@pacman_packages
def pacman_packages(self) -> set[str]:
return {
"fish",
"fzf",
"zsh",
"zsh-autosuggestions",
"zsh-completions",
"zsh-syntax-highlighting",
}
@aur_packages
def aur_packages(self) -> set[str]:
return {
"fzf-tab-git",
}
def after_update(self, store: object) -> None:
@@ -43,9 +37,8 @@ class ZshModule(Module):
check=False,
)
if result.returncode != 0:
decman.error(f"无法读取用户 {self.user} 的 passwd 信息")
return
raise decman.SourceError(f"无法读取用户 {self.user} 的 passwd 信息")
# passwd 格式: name:x:uid:gid:gecos:home:shell
shell = result.stdout.strip().split(":")[-1]
if shell != "/usr/bin/zsh":
decman.prg(["chsh", "-s", "/usr/bin/zsh", self.user])
if shell != "/usr/bin/fish":
decman.prg(["chsh", "-s", "/usr/bin/fish", self.user])
+7 -4
View File
@@ -5,7 +5,10 @@ REPO_URL="https://git.furtherverse.com/imbytecat/archlinux-config.git"
CONFIG_DIR="$HOME/.config/archlinux-config"
echo "🔑 验证 sudo 权限..."
sudo -v < /dev/tty || { echo "❌ 需要 sudo 权限,请确认当前用户已配置 sudo"; exit 1; }
sudo -v </dev/tty || {
echo "❌ 需要 sudo 权限,请确认当前用户已配置 sudo"
exit 1
}
echo "🔄 更新系统..."
sudo pacman -Syu --noconfirm
@@ -25,7 +28,7 @@ else
fi
echo "📦 安装 decman..."
if ! command -v decman &> /dev/null; then
if ! command -v decman &>/dev/null; then
_tmpdir=$(mktemp -d)
trap 'rm -rf "$_tmpdir"' EXIT
git clone https://aur.archlinux.org/decman.git "$_tmpdir"
@@ -33,10 +36,10 @@ if ! command -v decman &> /dev/null; then
fi
echo "⚙️ 应用系统配置..."
sudo decman --source "$CONFIG_DIR/source.py" < /dev/tty
sudo decman --source "$CONFIG_DIR/source.py" </dev/tty
echo ""
echo "🎉 安装完成!重新登录以使用 zsh。"
echo "🎉 安装完成!重新登录以使用 fish。"
echo ""
echo "后续更新配置:"
echo " cd $CONFIG_DIR && git pull && sudo decman"
+2 -2
View File
@@ -6,7 +6,7 @@ import modules.base
import modules.dev
import modules.docker
import modules.locale
import modules.zsh
import modules.fish
USERNAME = os.environ.get("SUDO_USER")
if not USERNAME:
@@ -17,5 +17,5 @@ decman.modules += [
modules.dev.DevModule(USERNAME),
modules.docker.DockerModule(USERNAME),
modules.locale.LocaleModule(),
modules.zsh.ZshModule(USERNAME),
modules.fish.FishModule(USERNAME),
]