Windows终端美化

一、安装windows终端

在windows store中下载安装windows terminal
也可以选择安装windows terminal preview

二、安装Git

Git for windows :https://gitforwindows.org/

在安装步骤中记得勾选

其余的按照默认来安装就可

安装完成后,可以打开windows Terminal查看选项卡中是否包含Git Bash

三、安装oh-my-zsh

1、下载zsh源文件

https://packages.msys2.org/package/zsh?repo=msys&variant=x86_64

2、解压下载的文件

可以使用以下工具进行解压

https://peazip.github.io/

https://github.com/mcmilk/7-Zip-zstd/releases

文件解压出来

若不想专门去下载解压工具,也可使用已经解压好的文件:zsh-5.9-2-x86_64.pkg.tar

将这些文件复制并覆盖到git安装目录下

3、安装oh-my-zsh

设置进入git bash后默认使用zsh

vim ~/.bashrc

if [ -t 1 ]; then
  exec zsh
fi

重启终端进入到zsh

如果无法进入到zsh,可能是解压的文件并不完整,尝试重新解压覆盖

执行以下命令安装oh-my-zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

安装完成后,可以观察到终端界面明显改变

此时表示oh-my-zsh安装完成

4、oh-my-zsh 终端美化及插件安装

zsh-syntax-highlighting

官网:https://github.com/zsh-users/zsh-syntax-highlighting

使用以下命令进行安装

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting
echo "source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

zsh-autosuggestions

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

使用以下命令进行安装

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
echo "source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

主题

官网及效果预览:https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

~/.zshrc 文件中设置主题,主题名称可从官网链接获取

ZSH_THEME="robbyrussell"

除了配置oh-my-zsh主题,我们还可以配置windows terminal主题

https://windowsterminalthemes.dev/
具体配置方案请自行查找

四、安装SDKMan

安装SDKMan可以方便的在各个java环境中切换,但只能切换命令行环境

sdkman需要使用zip命令来解压安装包,但git bash并不包含这个命令

因此要在git bash中安装sdkman,需要先安装zip

1、安装zip

https://sourceforge.net/projects/gnuwin32/files/zip/3.0/

选择下载 zip-3.0-bin.zip

将压缩包中的zip.exe,复制到git安装目录\mingw64\bin\

2、安装sdkman

执行以下命令

curl -s "https://get.sdkman.io" | zsh

等待安装完成之后,重启终端。

使用sdk help验证是否安装成功。

参考链接

https://juejin.cn/post/7122882640998301733

https://www.imlc.me/how-to-install-sdkman-in-git-bash/

posted @ 2023-01-01 18:25  Lrain.*  阅读(546)  评论(0编辑  收藏  举报