像MAC一樣使用win10的Terminal

Windows Terminal(Preview)實用、優(yōu)化技巧(含第三方Terminal工具介紹)
注意:Windows Terminal(Preview)只有 win10 1903以上的版本才有哦。

如果嫌棄下面的方式太麻煩的,還可以查看《像MAC一樣使用win10的Terminal(精簡版)》

Windows Terminal

效果如圖:


image.png

一. 安裝

直接進入Microsoft Store:


image.png

二. 美化

# 美化要點:
1. 改主題 (Oh-My-Posh)
2. 改顏色主題
3. 換字體

1. 安裝scoop

環(huán)境要求:
Windows 版本不低于 Windows 7
Windows 中的 PowerShell 版本不低于 PowerShell 3
你能 正常、快速 的訪問 GitHub 并下載上面的資源
你的 Windows 用戶名為英文(Windows 用戶環(huán)境變量中路徑值不支持中文字符)

2. 運行Powershell

打開菜單,點擊:


Windows Terminal

輸入以下腳本:

# 保證允許本地腳本的執(zhí)行
set-executionpolicy remotesigned -scope currentuser

3. 安裝scoop

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

4. 安裝字體

Fantasque Sans Mono Nerd Font

# 搜索 nerd fonts,這里選擇是的FantasqueSansMono這個字體
scoop search FantasqueSansMono-NF
# 添加 nerd fonts 源
scoop bucket add 'nerd-fonts'
# 安裝 nerd fonts
scoop install FantasqueSansMono-NF

5. 安裝oh-my-posh(類似oh-my-zsh)

# 1. 安裝 choco
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

# 2. 安裝ConEmu
choco install ConEmu

# 3. 安裝 posh-git 和 oh-my-posh
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

# 4. 設(shè)置 Powershell 的 profile
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE

# 5. 粘貼以下內(nèi)容進 profile 文件
Import-Module posh-git
Import-Module oh-my-posh

# 查看主題
Get-PoshThemes

# Set-Theme 已經(jīng)被 Set-PoshPrompt 替代
# Paradox是主題名稱
Set-PoshPrompt -Theme Paradox

6. 換顏色 (這一步可以跳過)

如圖:


a969328f28e108ec6b84056e22a8f410.gif
# 安裝微軟官方顏色工具
scoop install colortool

# 查看已安裝主題
colortool -s

# 設(shè)置主題
colortool OneHalfDark

更多主題:Iterm2-color-schemes

7. 優(yōu)化ls命令的樣式

如圖:


image.png
# 1. 直接在powershell里運行(如果運行失敗請檢查是否安裝 PowerShellGet):
)
Install-Module Get-ChildItemColor

# 或者 

# git 安裝(上面成功了,就不需要再用 git 安裝)
git clone https://github.com/joonro/Get-ChildItemColor.git

# 2. 激活
Import-Module Get-ChildItemColor 

8. 我的配置文件

使用notepad $profile即可打開

Import-Module Get-ChildItemColor

$env:PYTHONIOENCODING="utf-8"
# Remove curl alias
If (Test-Path Alias:curl) {Remove-Item Alias:curl}
If (Test-Path Alias:curl) {Remove-Item Alias:curl}
# Remove-Item alias:ls -force
Set-Alias l Get-ChildItemColor -option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope

function GitLogPretty {
  git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all
}

function PrettyLS {
  colorls --light -A
}

function GitStat {git status}

function GoBack {Set-Location ..}

function GetMyIp {curl -L tool.lu/ip}
function UpdateScoop {scoop update; scoop update *}

function UpdateChoco {choco upgrade chocolatey}

Import-Module posh-git
Import-Module oh-my-posh
# $DefaultUser = 'spenc'

# Setup other alias
Set-Alias open Invoke-Item
Set-Alias .. GoBack
Set-Alias glola GitLogPretty
Set-Alias gst GitStat
Set-Alias myip GetMyIp
Set-Alias pls PrettyLS

# Set theme,據(jù)說Set-Theme 指令已經(jīng)被 Set-PoshPrompt 取代
Set-PoshPrompt robbyrussell

Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

?。?!重點備注:

例圖方案

{
  "name": "Nord",
  "background": "#2e3440",
  "foreground": "#eceff4",
  "brightBlack": "#2e3440",
  "brightBlue": "#5e81ac",
  "brightCyan": "#8fbcbb",
  "brightGreen": "#a3be8c",
  "brightPurple": "#b48ead",
  "brightRed": "#bf616a",
  "brightWhite": "#eceff4",
  "brightYellow": "#ebcb8b",
  "black": "#2e3440",
  "blue": "#5e81ac",
  "cyan": "#8fbcbb",
  "green": "#a3be8c",
  "purple": "#b48ead",
  "red": "#bf616a",
  "white": "#eceff4",
  "yellow": "#ebcb8b"
}

第三方Terminal

1. Fluent Terminal

如圖:


Fluent Terminal

2. Hyper

如圖:


Hyper

3. Terminus

如圖:


Terminus

相關(guān)工具

參考資料

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容