Windows10开发环境搭建(4) 给WSL配置漂亮且强大的zsh

1、oh-my-zsh项目地址及相关插件

oh-my-zsh https://github.com/ohmyzsh/ohmyzsh

oh-my-zsh plugins https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins

oh-my-zsh theme https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions

2、安装zsh

sudo apt install zsh

3、安装Oh My Zsh

Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either curl, wget or another similar tool.

Method Command 需科学外网

sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

3、开启插件

Enabling Plugins 使用vi编辑或直接使用VS Code打开更方便。

vi ~/.zshrc

需要打开哪些插件,就在 .zshrc这个文件中添加上插件名称。

plugins=(
  git
  bundler
  dotenv
  osx
  rake
  rbenv
  ruby
)

.zshrc文件所在的位置:

cd /home/eric
ls -la
code .  zshrc
cd .oh-my-zsh
cd plugins
ls

需要什么插件,就clone到.oh-my-zsh/custom/plugins目录中,然后.zshrc中加入,比如添加插件zsh-autosuggestions;重新打开终端生效。

git clone https://github.com/zsh-users/zsh-autosuggestions
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-completions
git clone https://github.com/zsh-users/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-docker
code .  zshrc
plugins=(
  git
	minikube
  zsh-autosuggestions
	zsh-completions
	zsh-syntax-highlighting
	zsh-docker
)

配置zsh终端打开VsCode
open .zshrc
然后在弹出的文档末尾处添加如下代码

# open vs code
function code {
    if [[ $# = 0 ]]
    then
        open -a "Visual Studio Code"
    else
        local argPath="$1"
        [[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
        open -a "Visual Studio Code" "$argPath"
    fi
}

最后执行

source .zshrc

使操作立即生效,我们就可以愉快的在命令行执行Vs的打开操作啦。

附终端操作命令

code 在终端直接打开VsCode
code . 在命令行当前所在目录打开
code file 特定打开某某文件,如code 1.txt,即用VsCode打开当前目录下的1.txt文件

Linux/Unix提供了很多种Shell,输入以下的命令查看有哪些Shell:
$ cat /etc/shells

posted @ 2021-07-28 12:42  SkyDBA  阅读(238)  评论(0)    收藏  举报