Compare commits
15 Commits
d1435c9380
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cd1c59f021 | |||
| 01cd8eff49 | |||
| 6281d1cc0c | |||
| 4a185c3b1d | |||
| 396ac72b24 | |||
| 64b191d71a | |||
| 502f707d62 | |||
| c5cc702462 | |||
| e08364e93b | |||
| e1117a254c | |||
| 7e0f85bd5e | |||
| efce79b7e8 | |||
| 413775fe0f | |||
| afbd77a94e | |||
| 0c0d6f6cca |
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,58 +1,54 @@
|
|||||||
if status is-interactive
|
if status is-interactive
|
||||||
# ========= 命令缩写(仅当目标命令存在)=========
|
# ========= 编辑器环境变量设置 ==========
|
||||||
# ls:优先 eza,其次 exa
|
set -l editor_cmd (if type -q vim; echo vim; else if type -q vi; echo vi; else; end)
|
||||||
if type -q eza
|
test -n "$editor_cmd"; and set -gx EDITOR $editor_cmd
|
||||||
abbr ls eza
|
test -n "$editor_cmd"; and set -gx VISUAL $editor_cmd
|
||||||
abbr ll eza -l
|
|
||||||
abbr la eza -a
|
|
||||||
abbr lal eza -la
|
|
||||||
else if type -q exa
|
|
||||||
abbr ls exa
|
|
||||||
abbr ll exa -l
|
|
||||||
abbr la exa -a
|
|
||||||
abbr lal exa -la
|
|
||||||
end
|
|
||||||
|
|
||||||
# cat/cap:优先 bat;仅 batcat 时补 bat 缩写(与其它环境一致)
|
# ========= Bash 常用命令增强/替代 ==========
|
||||||
if type -q bat
|
# 工具选择
|
||||||
abbr cat bat
|
set -l ls_cmd (if type -q eza; echo eza; else if type -q exa; echo exa; else; end)
|
||||||
abbr cap bat -p
|
set -l cat_cmd (if type -q bat; echo bat; else if type -q batcat; echo batcat; else; end)
|
||||||
else if type -q batcat
|
set -l find_cmd (if type -q fd; echo fd; else if type -q fdfind; echo fdfind; else; end)
|
||||||
abbr cat batcat
|
|
||||||
abbr cap batcat -p
|
# 处理特殊情况:根据选择的工具添加缩写
|
||||||
abbr bat batcat
|
test "$cat_cmd" = "batcat"; and abbr bat batcat
|
||||||
end
|
test "$find_cmd" = "fdfind"; and abbr fd fdfind
|
||||||
# find:优先 fd;仅存在 fdfind 时(如 Debian/Ubuntu)用其并补 fd 缩写
|
|
||||||
if type -q fd
|
# 使用 zoxide init 添加 cd 和 cdi 命令
|
||||||
abbr find fd
|
type -q zoxide; and zoxide init --cmd cd fish | source
|
||||||
else if type -q fdfind
|
|
||||||
abbr find fdfind
|
# 命令缩写配置
|
||||||
abbr fd fdfind
|
test -n "$ls_cmd"; and abbr ls $ls_cmd
|
||||||
end
|
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 rg; and abbr grep rg
|
||||||
type -q btop; and abbr top btop
|
type -q btop; and abbr top btop
|
||||||
type -q tldr; and abbr help tldr
|
type -q tldr; and abbr help tldr
|
||||||
|
|
||||||
|
# ========= 其他工具配置 ==========
|
||||||
type -q chezmoi; and abbr cz chezmoi
|
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:自动命令纠错 =========
|
# ========= thefuck:自动命令纠错 =========
|
||||||
type -q thefuck; and thefuck --alias | source
|
type -q thefuck; and thefuck --alias | source
|
||||||
|
|
||||||
# ========= zoxide:智能目录跳转 =========
|
# ========= fastfetch:启动信息显示(仅在第一次打开 shell 时) =========
|
||||||
# 使用 --cmd=cd:让 cd 也具备 zoxide 的跳转能力(交互式对应 cdi)
|
if status --is-login; and type -q fastfetch
|
||||||
type -q zoxide; and zoxide init --cmd=cd fish | source
|
fastfetch
|
||||||
|
|
||||||
# ========= 编辑器/查看器(优先 vim,否则 vi)=========
|
|
||||||
# SUDO_EDITOR:供 visudo / sudoedit 等使用;若仍打开 nano,需在 sudoers 中加 Defaults env_keep += "SUDO_EDITOR"
|
|
||||||
if type -q vim
|
|
||||||
set -gx EDITOR vim
|
|
||||||
set -gx VISUAL vim
|
|
||||||
set -gx SUDO_EDITOR vim
|
|
||||||
else if type -q vi
|
|
||||||
set -gx EDITOR vi
|
|
||||||
set -gx VISUAL vi
|
|
||||||
set -gx SUDO_EDITOR vi
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# ========= fastfetch:启动信息显示 =========
|
|
||||||
type -q fastfetch; and fastfetch
|
|
||||||
end
|
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。
|
# - 不使用 chezmoi 的 .tmpl 模板语法;通过运行时检测 apt/pacman/dnf。
|
||||||
# - 脚本尽量保持幂等(包已安装会自动跳过)。
|
# - 脚本尽量保持幂等(包已安装会自动跳过)。
|
||||||
|
|
||||||
SUDO=""
|
# 包管理器配置
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
PACKAGE_LIST="zoxide exa bat fd fd-find ripgrep btop tldr fzf git vim tmux fish fastfetch thefuck"
|
||||||
if command -v sudo >/dev/null 2>&1; then
|
declare -A UPDATE_COMMAND
|
||||||
SUDO="sudo"
|
declare -A INSTALL_COMMAND
|
||||||
else
|
UPDATE_COMMAND=(
|
||||||
echo "需要 sudo 权限才能安装包(当前非 root,且找不到 sudo)。" >&2
|
[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
|
exit 1
|
||||||
|
fi
|
||||||
|
SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装单个包函数
|
||||||
|
install_package() {
|
||||||
|
local install_cmd="$1"
|
||||||
|
local package="$2"
|
||||||
|
if $SUDO $install_cmd "$package"; then
|
||||||
|
log "✨ 安装 $package: ✓ 成功"
|
||||||
|
else
|
||||||
|
log "⚠️ 安装 $package: ✗ 跳过"
|
||||||
fi
|
fi
|
||||||
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
|
if command -v pacman >/dev/null 2>&1; then
|
||||||
# Arch/Manjaro:先同步并升级系统,再安装所需包
|
install_packages "pacman"
|
||||||
$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
|
elif command -v apt >/dev/null 2>&1; then
|
||||||
# Debian/Ubuntu:更新索引后再安装
|
install_packages "apt"
|
||||||
$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
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
# Fedora:更新元数据后再安装
|
install_packages "dnf"
|
||||||
$SUDO dnf makecache -y || true
|
|
||||||
$SUDO dnf install -y exa zoxide dust bat btop fd-find ripgrep fzf tldr
|
|
||||||
else
|
else
|
||||||
echo "未检测到 apt / pacman / dnf,跳过安装。" >&2
|
log "❌ 未检测到 apt / pacman / dnf,跳过安装。"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user