windows 终端

一、 ohmyposh

安装指南

打开 powershell

依次执行

winget install JanDeDobbeleer.OhMyPosh -s winget
$env:Path += ";C:\Users\user\AppData\Local\Programs\oh-my-posh\bin"
New-Item -Path $PROFILE -Type File -Force
notepad $PROFILE

添加

oh-my-posh init pwsh | Invoke-Expression
. $PROFILE

二、字体

1. 自动安装

oh-my-posh font install

2. 自选安装

进入 www.nerdfonts.com 选择喜欢的字体安装

3. 更换字体

记得在终端设置里面更换安装的字体

三、 自动补全

依次执行

Install-Module PSReadLine

Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History

notepad $profile

添加

# Shows navigable menu of all options when hitting Tab
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

# Autocompletion for arrow keys
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

# auto suggestions
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History

Liunx 终端

一、 ZSH

依次输入

apt install zsh
chsh -s /bin/zsh

输入密码即可

二、 oh my zsh

安装

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

三、 添加插件

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

ZSH_CUSTOM=~/.oh-my-zsh/custom

# 自动高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
# 自动提示
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
# 自动补全
git clone https://github.com/zsh-users/zsh-completions $ZSH_CUSTOM/plugins/zsh-completions

! grep -q "autoload -U compinit && compinit" ~/.zshrc && echo "autoload -U compinit && compinit" >> ~/.zshrc
sed -i '/^plugins=/c\plugins=(git sudo z zsh-syntax-highlighting zsh-autosuggestions zsh-completions)' ~/.zshrc

四、添加主题

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

sed -i '/^ZSH_THEME=/c\ZSH_THEME="powerlevel10k/powerlevel10k"' ~/.zshrc

重新进入终端即可开始配置主题

配置不满意?重新开始配置 p10k configure