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

一、前置准备

(一)安装zsh:

sudo apt install -y zsh

(二)安装git:

sudo apt install -y git

二、安装 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(zsh-autosuggestions zsh-syntax-highlighting)
# 使修改生效
source ~/.zshrc

你可能感兴趣的:(经验积累,git,github,ubuntu)