Ubuntu 安装好用的 shell 工具 oh-my-zsh

该文详细介绍了如何在Ubuntu系统中安装zsh和git,然后通过两种方式安装oh-my-zsh。接着,文章指导读者如何将zsh设为默认shell,并安装了两个增强功能的插件:zsh-autosuggestions和zsh-syntax-highlighting,最后更新zshrc文件使插件生效。

一、前置准备

(一)安装zsh:

sudo apt install -y zsh

(二)安装git:

sudo apt install -y git

 

(三)安装wget:

sudo apt install -y wget

二、安装 oh-my-zsh

# 方法一:因为要访问github仓库,此处依据网络状态,可能需要科学上网
sudo wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

# 方法二:可以使用国内源安装
# 第一步:下载安装脚本
sudo wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
# 第二步:修改安装脚本内容,将其中的来源改为码云
# 编辑打开install.sh文件,找到以下部分:
# # Default settings 
# ZSH=${ZSH:-~/.oh-my-zsh} 
# REPO=${REPO:-ohmyzsh/ohmyzsh} 
# REMOTE=${REMOTE:-https://github.com/${REPO}.git} 
# BRANCH=${BRANCH:-master}
#
# 将 REPO=${REPO:-ohmyzsh/ohmyzsh} 和 REMOTE=${REMOTE:-https://github.com/${REPO}.git}
# 改为:
REPO=${REPO:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
# 保存,通过sh运行脚本安装
sudo sh install.sh
# 第三步:修改仓库源
cd ~/.oh-my-zsh
git remote set-url origin https://gitee.com/mirrors/oh-my-zsh.git 
git pull

三、配置 oh-my-zsh

(一)设置zsh为系统默认shell

        1. 为root用户修改默认shell为zsh

sudo chsh -s /bin/zsh root

        2. 为当前用户修改默认shell为zsh

sudo chsh -s /bin/zsh

        3. 恢复命令

sudo chsh -s /bin/bash

(二)安装插件:

        1. zsh-autosuggestions

# github 源
sudo git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# gitee 源
sudo git clone https://gitee.com/hailin_cool/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

        2. highlighting

# github 源
sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# gitee 源
sudo git clone https://gitee.com/Greenplumwine/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

(三)使插件生效

# 打开编辑 zshrc 文件
vim ~/.zshrc
# 然后再.zshrc里面找到plugins,在plugins里面加上zsh-autosuggestions和zsh-syntax-highlighting
# 将 plugins(git) 修改如下:
plugins(git zsh-autosuggestions zsh-syntax-highlighting)
# 使修改生效
source ~/.zshrc

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值