2 mins
Debian 配置 zsh 和 oh-my-zsh 指南
本文详细介绍了如何在 Debian 系统上配置 zsh 和 oh-my-zsh,包括安装 zsh、设置为默认 Shell、安装 oh-my-zsh 以 及推荐的插件列表。通过本文, 您可以轻松地将 zsh 配置为强大的 命令行工具,并利用 oh-my-zsh 提供的 丰富功能和插件提升工作效率.

安装 zshh2
zsh 是一个强大的 Shell,提供了许多增强功能和更好的用户体验。首先,我们需要更新包列表并安装 zsh:
sudo apt updatesudo apt install zsh
# 验证安装版本:zsh --version
## 2. 设置 zsh 为默认 Shell
chsh -s $(which zsh)
echo $SHELL # 应显示xxx/zsh
安装 oh-my-zshh2
通过官方脚本安装(任选一种):
# 使用 curlsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 或使用 wgetsh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
插件h3
效率增强
插件名称 | 功能描述 | 安装命令 |
---|---|---|
zsh-autosuggestions | 历史命令自动提示 | git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM}/plugins/zsh-autosuggestions |
zsh-syntax-highlighting | 实时语法高亮 | git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting |
fzf | 模糊搜索文件/命令 | sudo apt install fzf && git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install |
** Git 工具**
插件名称 | 功能描述 | 备注 |
---|---|---|
git | 内置 Git 快捷命令 | 如 gst =git status |
git-extras | 扩展 Git 命令 | 需额外安装:sudo apt install git-extras |
gitfast | 快速 Git 补全 | 适合大型仓库 |
开发工具
插件名称 | 支持工具 |
---|---|
docker | Docker 命令补全 |
npm | npm 包管理补全 |
python | Python 相关工具补全 |
系统管理
插件名称 | 功能描述 |
---|---|
systemd | systemctl 命令补全 |
sudo | 按两次 ESC 快速添加 sudo |
tmux | Tmux 会话管理 |
趣味插件
plugins=(... emoji cowsay)
需先安装 cowsay
:
sudo apt install cowsay
完整配置示例
.zshrc
片段:
plugins=( git zsh-autosuggestions zsh-syntax-highlighting fzf docker systemd sudo emoji)
补充h2
Tmuxh3
apt install tmux -y || yum install tmux -ycurl -SsL https://pan.0197011.xyz/down/s/tmux.sh | bash
命令替代h3
apt install btop -y || yum install btop -y