zsh安装、配置
安装zsh
sudo apt install zsh
安装oh-my-zsh
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
给 install.sh 赋予运行权限
chmod +x install.sh
国内使用 gitee 需要打开 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:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
运行 install.sh
./install.sh
上述操作来源于博客oh-my-zsh 国内安装及配置_oh my zsh-CSDN博客
安装powerlevel10k主题
github
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
gitee
git clone https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
我拉取项目时出现问题,从github安装时中断退出下载
报错信息
Cloning into '/home/lzh/.oh-my-zsh/custom/themes/powerlevel10k'...
remote: Enumerating objects: 16429, done.
remote: Counting objects: 100% (4164/4164), done.
remote: Compressing objects: 100% (151/151), done.
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
error: 6641 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
经过网上的查找,我认为这是因为拉取的项目偏大,服务器的网络不好导致的。
我最后直接使用gitee解决,现在想来应该是使用--depth=1
,只获取最近一次的commit,减少下载量。
修改.zshrc
中的主题
ZSH_THEME="powerlevel10k/powerlevel10k"
配置wsl使用windows代理
代理软件使用的是v2ragN
允许来自局域网的连接
左下角查看代理端口
修改.zshrc
,添加命令
# add proxy
# proxy 命令 启动代理
function proxy() {
# hostip wsl 使用的ip
export hostip=$(ip route | grep default | awk '{print $3}')
export socks_hostport=10810
export http_hostport=10811
export https_proxy="http://${hostip}:${http_hostport}"
export http_proxy="http://${hostip}:${http_hostport}"
export ALL_PROXY="socks5://${hostip}:${socks_hostport}"
export all_proxy="socks5://${hostip}:${socks_hostport}"
}
# unproxy 命令 结束代理
function unproxy() {
unset ALL_PROXY
unset https_proxy
unset http_proxy
unset all_proxy
}
# echoproxy 命令 输出代理地址
function echoproxy() {
echo $ALL_PROXY
echo $all_proxy
echo $https_proxy
echo $http_proxy
}
#end proxy
安装zsh插件
安装命令提示
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
安装命令高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
修改.zshrc
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)