
【实践记录】快速构建一套好用的zsh环境
环境介绍
- 操作系统:Debian 12 (Bash)
- 网络环境:良好(复杂网络环境下推荐参考各类教程中的gitee.com或其它镜像站)
操作步骤
详细配置和插件特性参考官方文档,连接至参考阅读。
01 安装zsh并下载插件资源
# 安装zsh并切换默认shell
sudo apt install -y zsh
chsh -s /bin/zsh
# 安装ohmyzsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 主题 powerlevel10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
# 高亮插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
# 自动提示
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
# 基于频率的cd简化插件
git clone https://github.com/rupa/z.git $ZSH_CUSTOM/plugins/z
# 模糊查找工具
git clone https://github.com/Aloxaf/fzf-tab ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-tab
# fzf-tab依赖fzf工具,apt仓库中的fzf版本过于老旧,推荐前往仓库realease自行下载解压并放入Bin
# https://github.com/junegunn/fzf/releases
02 编辑配置文件
vim ~/.zshrc
# 解开第二行的 export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
# 修改主题ZSH_THEME="powerlevel10k/powerlevel10k"
# 找到plugins部分,添加插件配置如下:
plugins=(git
zsh-syntax-highlighting
zsh-autosuggestions
z
fzf-tab
)
# 推荐添加fzf快捷操作
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
alias f="fzf --height 80% --preview 'bat --style=numbers --color=always --line-range :500 {}' --preview-window right,70%,border-horizontal"
退出并保存。
03 完成安装
source ~/.zshrc
# 然后跟随powerlevel10k的安装指引进行配置,完成配置后还可进入配置文件重新修改
推荐工具
- X-CMD | 模块化构建的命令行工具集, 提供 1000+ 轻量且高效的命令, 秒级启动
- TheR1D/shell_gpt: A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
- aristocratos/btop: A monitor of resources
- fastfetch-cli/fastfetch: A maintained, feature-rich and performance oriented, neofetch like system information tool.
参考阅读
- 主题:romkatv/powerlevel10k: A Zsh theme
- fzf:junegunn/fzf: :cherry_blossom: A command-line fuzzy finder
- ZSH配置 - Leo Blog
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 光溯星河
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果