Debian 配置 zsh 和 oh-my-zsh 指南

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

安装 zsh

zsh 是一个强大的 Shell,提供了许多增强功能和更好的用户体验。首先,我们需要更新包列表并安装 zsh:

1
2
3
4
5
6
7
8
9
sudo apt update
sudo apt install zsh

# 验证安装版本:
zsh --version

## 2. 设置 zsh 为默认 Shell

chsh -s $(which zsh)
1
echo $SHELL  # 应显示xxx/zsh

安装 oh-my-zsh

通过官方脚本安装(任选一种):

1
2
3
4
5
# 使用 curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 或使用 wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

插件

效率增强

插件名称 功能描述 安装命令
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 会话管理

趣味插件

1
plugins=(... emoji cowsay)

需先安装 cowsay

1
sudo apt install cowsay

完整配置示例

.zshrc 片段:

1
2
3
4
5
6
7
8
9
10
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
fzf
docker
systemd
sudo
emoji
)

补充

Tmux

command
1
2
apt install tmux -y || yum install tmux -y
curl -SsL https://pan.0197011.xyz/down/s/tmux.sh | bash

命令替代

command
1
apt install btop  -y  || yum install btop -y

Debian 配置 zsh 和 oh-my-zsh 指南

https://www.mutter.cn/debian-zsh-oh-my-zsh/

作者

默吟

发布于

2025-06-06

许可协议

CC BY-NC-SA 4.0

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×