Compare commits
19 Commits
c7e31a1133
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cd1c59f021 | |||
| 01cd8eff49 | |||
| 6281d1cc0c | |||
| 4a185c3b1d | |||
| 396ac72b24 | |||
| 64b191d71a | |||
| 502f707d62 | |||
| c5cc702462 | |||
| e08364e93b | |||
| e1117a254c | |||
| 7e0f85bd5e | |||
| efce79b7e8 | |||
| 413775fe0f | |||
| afbd77a94e | |||
| 0c0d6f6cca | |||
| d1435c9380 | |||
| 6fbc23910e | |||
| a323153e5d | |||
| 4566314b11 |
2
.chezmoiignore
Normal file
2
.chezmoiignore
Normal file
@@ -0,0 +1,2 @@
|
||||
# 各类程序生成的日志,不纳入 dotfiles 管理
|
||||
**/*.log
|
||||
19
dot_config/README.md
Normal file
19
dot_config/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Dotfiles 工具列表
|
||||
|
||||
## Bash 常用命令增强/替代
|
||||
- **zoxide** - 智能目录跳转
|
||||
- **eza / exa** - 替代 `ls`
|
||||
- **bat / batcat** - 替代 `cat`
|
||||
- **fd / fdfind** - 替代 `find`
|
||||
- **ripgrep (rg)** - 替代 `grep`
|
||||
- **btop** - 替代 `top`
|
||||
- **tldr** - 替代 `man`
|
||||
- **fzf** - 模糊搜索工具
|
||||
|
||||
## 其他工具
|
||||
- **Fish Shell** - 现代化 shell
|
||||
- **Tmux** - 终端复用器
|
||||
- **Git** - 版本控制
|
||||
- **vim** - 文本编辑器
|
||||
- **fastfetch** - 系统信息显示
|
||||
- **thefuck** - 命令纠错
|
||||
@@ -1,40 +1,54 @@
|
||||
if status is-interactive
|
||||
# ========= 命令缩写(仅当目标命令存在)=========
|
||||
# ls:优先 eza,其次 exa
|
||||
if type -q eza
|
||||
abbr ls eza
|
||||
abbr ll eza -l
|
||||
abbr la eza -a
|
||||
else if type -q exa
|
||||
abbr ls exa
|
||||
abbr ll exa -l
|
||||
abbr la exa -a
|
||||
end
|
||||
# ========= 编辑器环境变量设置 ==========
|
||||
set -l editor_cmd (if type -q vim; echo vim; else if type -q vi; echo vi; else; end)
|
||||
test -n "$editor_cmd"; and set -gx EDITOR $editor_cmd
|
||||
test -n "$editor_cmd"; and set -gx VISUAL $editor_cmd
|
||||
|
||||
type -q bat; and abbr cat bat
|
||||
type -q bat; and abbr cap bat -p
|
||||
type -q fd; and abbr find fd
|
||||
# ========= Bash 常用命令增强/替代 ==========
|
||||
# 工具选择
|
||||
set -l ls_cmd (if type -q eza; echo eza; else if type -q exa; echo exa; else; end)
|
||||
set -l cat_cmd (if type -q bat; echo bat; else if type -q batcat; echo batcat; else; end)
|
||||
set -l find_cmd (if type -q fd; echo fd; else if type -q fdfind; echo fdfind; else; end)
|
||||
|
||||
# 处理特殊情况:根据选择的工具添加缩写
|
||||
test "$cat_cmd" = "batcat"; and abbr bat batcat
|
||||
test "$find_cmd" = "fdfind"; and abbr fd fdfind
|
||||
|
||||
# 使用 zoxide init 添加 cd 和 cdi 命令
|
||||
type -q zoxide; and zoxide init --cmd cd fish | source
|
||||
|
||||
# 命令缩写配置
|
||||
test -n "$ls_cmd"; and abbr ls $ls_cmd
|
||||
test -n "$ls_cmd"; and abbr ll "$ls_cmd -l"
|
||||
test -n "$ls_cmd"; and abbr la "$ls_cmd -a"
|
||||
test -n "$ls_cmd"; and abbr lal "$ls_cmd -la"
|
||||
test -n "$cat_cmd"; and abbr cat $cat_cmd
|
||||
test -n "$cat_cmd"; and abbr cap "$cat_cmd -p"
|
||||
test -n "$find_cmd"; and abbr find $find_cmd
|
||||
type -q rg; and abbr grep rg
|
||||
type -q btop; and abbr top btop
|
||||
type -q tldr; and abbr help tldr
|
||||
|
||||
# ========= 其他工具配置 ==========
|
||||
type -q chezmoi; and abbr cz chezmoi
|
||||
type -q tmux; and abbr tm tmux
|
||||
type -q tmux; and abbr tmn 'tmux new'
|
||||
type -q tmux; and abbr tma 'tmux attach'
|
||||
type -q tmux; and abbr tml 'tmux list-sessions'
|
||||
type -q docker; and abbr d docker
|
||||
type -q docker-compose; and abbr dc 'docker-compose'
|
||||
|
||||
# systemd 常用缩写
|
||||
type -q systemctl; and abbr sc systemctl
|
||||
type -q systemctl; and abbr scu 'systemctl --user'
|
||||
type -q journalctl; and abbr jc journalctl
|
||||
type -q journalctl; and abbr jcu 'journalctl --user'
|
||||
|
||||
# ========= thefuck:自动命令纠错 =========
|
||||
type -q thefuck; and thefuck --alias | source
|
||||
|
||||
# ========= zoxide:智能目录跳转 =========
|
||||
# 使用 --cmd=cd:让 cd 也具备 zoxide 的跳转能力(交互式对应 cdi)
|
||||
type -q zoxide; and zoxide init --cmd=cd fish | source
|
||||
|
||||
# ========= 编辑器/查看器(优先 vim,否则 vi)=========
|
||||
if type -q vim
|
||||
set -gx EDITOR vim
|
||||
set -gx VISUAL vim
|
||||
else if type -q vi
|
||||
set -gx EDITOR vi
|
||||
set -gx VISUAL vi
|
||||
# ========= fastfetch:启动信息显示(仅在第一次打开 shell 时) =========
|
||||
if status --is-login; and type -q fastfetch
|
||||
fastfetch
|
||||
end
|
||||
|
||||
# ========= fastfetch:启动信息显示 =========
|
||||
type -q fastfetch; and fastfetch
|
||||
end
|
||||
|
||||
41
dot_config/tmux/tmux.conf
Normal file
41
dot_config/tmux/tmux.conf
Normal file
@@ -0,0 +1,41 @@
|
||||
# --- 1. 核心体验优化 ---
|
||||
set -g mouse on # 开启鼠标支持:点击换面板、滚轮翻日志、拖动改分屏大小
|
||||
set -g base-index 1 # 窗口编号从 1 开始(对应键盘数字键 1-9,0 太远了)
|
||||
set -g pane-base-index 1 # 面板编号也从 1 开始
|
||||
set -s escape-time 0 # 解决在 Emacs/Vim 中按 ESC 键有延迟的问题
|
||||
set -g history-limit 50000 # 增加滚动回溯行数(默认 2000 太短了)
|
||||
|
||||
# --- 2. 快捷键重绑定 ---
|
||||
# 将前缀键改为 Ctrl + a
|
||||
unbind C-b
|
||||
set -g prefix C-a
|
||||
bind C-a send-prefix
|
||||
|
||||
# 更直观的分屏快捷键
|
||||
bind v split-window -h -c "#{pane_current_path}" # v键垂直分屏
|
||||
bind h split-window -v -c "#{pane_current_path}" # h键水平分屏
|
||||
|
||||
# 使用 Alt + hjkl 切换面板(Vim 风格)
|
||||
bind -n M-h select-pane -L
|
||||
bind -n M-l select-pane -R
|
||||
bind -n M-k select-pane -U
|
||||
bind -n M-j select-pane -D
|
||||
|
||||
# 使用 Alt + Shift + hjkl 调整面板大小
|
||||
bind -n M-H resize-pane -L 5
|
||||
bind -n M-L resize-pane -R 5
|
||||
bind -n M-K resize-pane -U 5
|
||||
bind -n M-J resize-pane -D 5
|
||||
|
||||
# 快速重载配置 (Prefix + r)
|
||||
bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"
|
||||
|
||||
# --- 3. 视觉与显示 ---
|
||||
# 开启真彩色支持
|
||||
set -g default-terminal "screen-256color"
|
||||
set-option -ga terminal-overrides ",xterm-256color:Tc"
|
||||
|
||||
# 简单的状态栏美化
|
||||
set -g status-style "bg=#333333,fg=#5eacd3"
|
||||
set -g status-left "#[fg=green][#S] " # 左侧显示会话名
|
||||
set -g status-right "%H:%M %Y-%m-%d" # 右侧显示时间
|
||||
@@ -6,29 +6,66 @@ set -euo pipefail
|
||||
# - 不使用 chezmoi 的 .tmpl 模板语法;通过运行时检测 apt/pacman/dnf。
|
||||
# - 脚本尽量保持幂等(包已安装会自动跳过)。
|
||||
|
||||
SUDO=""
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
SUDO="sudo"
|
||||
else
|
||||
echo "需要 sudo 权限才能安装包(当前非 root,且找不到 sudo)。" >&2
|
||||
# 包管理器配置
|
||||
PACKAGE_LIST="zoxide exa bat fd fd-find ripgrep btop tldr fzf git vim tmux fish fastfetch thefuck"
|
||||
declare -A UPDATE_COMMAND
|
||||
declare -A INSTALL_COMMAND
|
||||
UPDATE_COMMAND=(
|
||||
[pacman]="pacman -Syu --noconfirm"
|
||||
[apt]="apt update"
|
||||
[dnf]="dnf makecache -y"
|
||||
)
|
||||
INSTALL_COMMAND=(
|
||||
[pacman]="pacman -S --noconfirm"
|
||||
[apt]="apt install -y"
|
||||
[dnf]="dnf install -y"
|
||||
)
|
||||
|
||||
# 输出函数
|
||||
log() { echo -e "\033[34m$1\033[0m"; }
|
||||
|
||||
# 检查 sudo 权限(假设普通用户运行)
|
||||
if ! command -v sudo >/dev/null 2>&1; then
|
||||
log "❌ 需要sudo 权限才能安装包。"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
SUDO="sudo"
|
||||
|
||||
if command -v pacman >/dev/null 2>&1; then
|
||||
# Arch/Manjaro:先同步并升级系统,再安装所需包
|
||||
$SUDO pacman -Syu --noconfirm
|
||||
$SUDO pacman -S --noconfirm exa zoxide dust bat btop fd ripgrep fzf tldr
|
||||
elif command -v apt >/dev/null 2>&1; then
|
||||
# Debian/Ubuntu:更新索引后再安装
|
||||
$SUDO apt update -y || true
|
||||
$SUDO apt install -y fzf zoxide ripgrep bat fd-find btop exa
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
# Fedora:更新元数据后再安装
|
||||
$SUDO dnf makecache -y || true
|
||||
$SUDO dnf install -y exa zoxide dust bat btop fd-find ripgrep fzf tldr
|
||||
# 安装单个包函数
|
||||
install_package() {
|
||||
local install_cmd="$1"
|
||||
local package="$2"
|
||||
if $SUDO $install_cmd "$package"; then
|
||||
log "✨ 安装 $package: ✓ 成功"
|
||||
else
|
||||
echo "未检测到 apt / pacman / dnf,跳过安装。" >&2
|
||||
log "⚠️ 安装 $package: ✗ 跳过"
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装包函数
|
||||
install_packages() {
|
||||
local package_manager="$1"
|
||||
|
||||
log "🔍 检测到 $package_manager,开始安装包..."
|
||||
log "📦 更新包..."
|
||||
$SUDO ${UPDATE_COMMAND[$package_manager]}
|
||||
log "🚀 开始安装包..."
|
||||
|
||||
for package in $PACKAGE_LIST; do
|
||||
install_package "${INSTALL_COMMAND[$package_manager]}" "$package"
|
||||
done
|
||||
|
||||
log "✅ $package_manager 包安装完成!"
|
||||
}
|
||||
|
||||
# 主逻辑:检测包管理器并安装
|
||||
if command -v pacman >/dev/null 2>&1; then
|
||||
install_packages "pacman"
|
||||
elif command -v apt >/dev/null 2>&1; then
|
||||
install_packages "apt"
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
install_packages "dnf"
|
||||
else
|
||||
log "❌ 未检测到 apt / pacman / dnf,跳过安装。"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user