Loading

Ubutun 安装 zsh 和 oh-my-zsh

安装 zsh

Z shell(Zsh)是一款可用作交互式登录的shell及脚本编写的命令解释器。Zsh对Bourne shell做出了大量改进,同时加入了Bash、ksh及tcsh的某些功能。

# 查看有哪些 shell
cat /etc/shells

# 安装
sudo apt install zsh

# 将 zsh 设置为默认 shell
chsh -s /bin/zsh

# 检查
echo $SHELL

# 返回 /bin/zsh 即表示成功;若没成功,重启终端试试看

安装 oh my zsh

Oh My Zsh 是基于 Zsh 命令行的一个扩展工具集,提供了丰富的扩展功能,如:主题配置,插件机制,内置的便捷操作等,,可以给我们一种全新的命令行使用体验

# 1. 通过 curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 2. 通过 wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 3. 通过 git
cd ~
git clone https://github.com/ohmyzsh/ohmyzsh ohmyzsh
cd ./tools
sh install.sh

配置

vim ~/.zshrc

# 更换主题,默认主题安装目录`ohmyzsh/themes`
ZSH_THEME='random'
# 注: 每次登陆随机一种主题,喜欢可以直接修改为对应主题

# 启动错误命令自动更正
ENABLE_CORRECTION="true"

# 在命令执行的过程中,使用小红点进行提示
COMPLETION_WAITING_DOTS="true"

# 启用已安装的插件,默认插件安装目录 `ohmyzsh/plugins`
plugins=(
    colorize 
    colored-man-pages 
    extract 
    git
    screen
    web-search
    z
    zsh-autosuggestions 
    zsh-syntax-highlighting 
    git-open
)

主题效果列表

Themes · ohmyzsh/ohmyzsh Wiki (github.com)

自带插件

  • 跟踪最常访问的目录 - z
  • 网页搜索插件 - web-search plugin
  • 解压压缩包插件 - extract

安装插件

# 手工安装插件
cd ~/.oh-my-zsh/plugins
# 1. 自动补全
git clone https://github.com/zsh-users/zsh-autosuggestions zsh-autosuggestions
# 2. 代码高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting zsh-syntax-highlighting
# 3. 快速打开 GitHub 仓库
git clone https://github.com/paulirish/git-open git-open
# 更新 zsh 配置文件
source ~/.zshrc

安装字体

# 克隆字体
git clone https://github.com/powerline/fonts --depth=1

# 安装字体
cd fonts
./install.sh

# 清理环境
cd ..
rm -rf fonts

参考链接:https://zhuyuanxiang.github.io/os/Ubuntu-zsh/

posted @ 2023-02-17 23:31  紫曜花  阅读(195)  评论(0编辑  收藏  举报