2023.12.09-配置zsh

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

允许来自局域网的连接

image-20231209214551886

左下角查看代理端口

image-20231209214723671

修改.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

image-20231209215154094

image-20231209215323249

安装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
        )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值