ZSH安装与配置

安装

安装 zsh

Copy
sudo apt-get update
sudo apt-get upgrade
apt-get install git,zsh
zsh --version

Shell 切换

切换为 Bash

Copy
echo $SHELL
which bash
sudo chsh -s $(which bash)

切换为 zsh

Copy
echo $SHELL
zsh --version
which zsh
sudo chsh -s $(which zsh) #sudo用于root用户
restart
reboot

Oh-my-zsh 安装与配置

https://ohmyz.sh/#install

安装

Copy
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
#国内镜像
sh -c "$(curl -fsSL https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"
sh -c "$(wget -O- https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"

主题

Copy
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
# 国内镜像
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"

ZSH_THEME="powerlevel10k/powerlevel10k"
source ~/.zshrc
p10k configure

插件

Zsh-syntax-highlighting

Zsh-autosuggestions

zsh-completions

Copy
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone --depth=1 https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions

zsh-completions
plugins=(evalcache git git-extras debian tmux screen history extract colorize web-search docker zsh-completions zsh-autosuggestions zsh-syntax-highlighting)

source ~/.zshrc

配置

Copy
# proxy func
proxy () {
export http_proxy="http://127.0.0.1:8087"
export https_proxy="http://127.0.0.1:8087"
echo "HTTP Proxy on"
}
noproxy () {
unset http_proxy
unset https_proxy
echo "HTTP Proxy off"
} # end proxy

让 Zsh 终端走代理 | 纸帆 | ZevenFang

更新

Copy
upgrade_oh_my_zsh

卸载

Copy
uninstall_oh_my_zsh

🔗参考链接

zsh 安装与配置，使用 oh-my-zsh 美化终端 | Leehow 的小站
使用 Zsh 作为 Ubuntu 的默认 Shell
Linux 全局安装配置 zsh + oh-my-zsh - sysin | SYStem INside | 软件与技术分享