oh my zsh安装使用

708 阅读1分钟

1.安装ZSH

ZSH:github.com/ohmyzsh/ohm…

Ubuntu

sudo apt install zsh

2.安装oh my zsh

oh my zsh:github.com/ohmyzsh/ohm…

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)"

国内安装

原文:touka.dev/tech/oh-my-…

下载码云安装包
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}
编辑后保存, 运行安装即可. (运行前先给install.sh权限)

修改仓库地址
cd ~/.oh-my-zsh
git remote set-url origin https://gitee.com/mirrors/oh-my-zsh.git
git pull

3.安装主题和常用插件

plugins:github.com/ohmyzsh/ohm… themes:github.com/ohmyzsh/ohm…

好用的插件推荐:juejin.cn/post/684490…

vi ~/.zshrc 修改文件

  1. 主题:ZSH_THEME="jonathan"

  2. 插件:plugins=(git)


可能遇到的问题

使用sudo安装ZSH的时候会报错:xxx is not in the sudoers file. This incident will be reported.

原文:www.linuxidc.com/Linux/2016-…

解决

1.切换到root用户下

2./etc/sudoers文件默认是只读的,对root来说也是,因此需先添加sudoers文件的写权限,命令是: chmod u+w /etc/sudoers

3.编辑sudoers文件 vi /etc/sudoers 找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)

ps:这里说下你可以sudoers添加下面四行中任意一条 youuser ALL=(ALL) ALL %youuser ALL=(ALL) ALL youuser ALL=(ALL) NOPASSWD: ALL %youuser ALL=(ALL) NOPASSWD: ALL

第一行:允许用户youuser执行sudo命令(需要输入密码). 第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码). 第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码. 第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.

4.撤销sudoers文件写权限,命令: chmod u-w /etc/sudoers