Compare commits
9 Commits
e1117a254c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cd1c59f021 | |||
| 01cd8eff49 | |||
| 6281d1cc0c | |||
| 4a185c3b1d | |||
| 396ac72b24 | |||
| 64b191d71a | |||
| 502f707d62 | |||
| c5cc702462 | |||
| e08364e93b |
@@ -8,6 +8,7 @@
|
|||||||
- **ripgrep (rg)** - 替代 `grep`
|
- **ripgrep (rg)** - 替代 `grep`
|
||||||
- **btop** - 替代 `top`
|
- **btop** - 替代 `top`
|
||||||
- **tldr** - 替代 `man`
|
- **tldr** - 替代 `man`
|
||||||
|
- **fzf** - 模糊搜索工具
|
||||||
|
|
||||||
## 其他工具
|
## 其他工具
|
||||||
- **Fish Shell** - 现代化 shell
|
- **Fish Shell** - 现代化 shell
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ if status is-interactive
|
|||||||
test "$cat_cmd" = "batcat"; and abbr bat batcat
|
test "$cat_cmd" = "batcat"; and abbr bat batcat
|
||||||
test "$find_cmd" = "fdfind"; and abbr fd fdfind
|
test "$find_cmd" = "fdfind"; and abbr fd fdfind
|
||||||
|
|
||||||
# 使用 --cmd=cd:让 cd 也具备 zoxide 的跳转能力(交互式对应 cdi)
|
# 使用 zoxide init 添加 cd 和 cdi 命令
|
||||||
type -q zoxide; and zoxide init --cmd=cd fish | source
|
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 ls $ls_cmd
|
||||||
@@ -35,6 +35,14 @@ if status is-interactive
|
|||||||
type -q tmux; and abbr tmn 'tmux new'
|
type -q tmux; and abbr tmn 'tmux new'
|
||||||
type -q tmux; and abbr tma 'tmux attach'
|
type -q tmux; and abbr tma 'tmux attach'
|
||||||
type -q tmux; and abbr tml 'tmux list-sessions'
|
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
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
|
||||||
|
SUDO="sudo"
|
||||||
|
|
||||||
|
# 安装单个包函数
|
||||||
|
install_package() {
|
||||||
|
local install_cmd="$1"
|
||||||
|
local package="$2"
|
||||||
|
if $SUDO $install_cmd "$package"; then
|
||||||
|
log "✨ 安装 $package: ✓ 成功"
|
||||||
else
|
else
|
||||||
echo "需要 sudo 权限才能安装包(当前非 root,且找不到 sudo)。" >&2
|
log "⚠️ 安装 $package: ✗ 跳过"
|
||||||
exit 1
|
|
||||||
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 git vim tmux
|
|
||||||
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 git vim tmux
|
|
||||||
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 git vim tmux
|
|
||||||
else
|
else
|
||||||
echo "未检测到 apt / pacman / dnf,跳过安装。" >&2
|
log "❌ 未检测到 apt / pacman / dnf,跳过安装。"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user