Windows Terminal 介绍
官方github地址:https://github.com/microsoft/terminal
少数派:https://sspai.com/post/59380
新晋 Windows 终端模拟器:Windows Terminal ,自发布以来就备受开发者的喜爱,并与 WSL 一起,让不少先前非 Linux 不用的开发者朋友们向 Windows 倾斜。Windows Terminal 不仅开源免费,还拥有现代化的界面、完整的字体字符渲染机制(包括 Emoji)、GPU 加速和 Fluent 设计风格。这些都让 Windows Terminal 成为 Windows 平台最先进的终端模拟器,力压一众第三方终端以及 Windows 自带的默认终端。
支持WSL2,SSH,Powershell,cmd和其他命令行
多个选项卡和拆分窗格
搜索框
自定义键绑定
GPU加速文字渲染
美观的新字体Cascadia Code
资源使用率低(每个选项卡通常10MB)
自动更新(如果使用Microsoft Store)
Windows Terminal 2.0 开发路线图:https://github.com/microsoft/terminal/blob/main/doc/terminal-v2-roadmap.md
安装 Windows Terminal 在官方 README 中,安装Windows Terminal有如下方法:
这里使用Microsoft Store进行安装,简单直接,还能自动更新【doge】
Windows Terminal 配置
官方配置文档:https://docs.microsoft.com/zh-cn/windows/terminal/customize-settings/profile-general
1 2 ctrl + ,进入设置页面 目前版本已经实现大部分内容的可视化设置。。。
1 进入设置界面后,左下角点击设置按钮,即可编辑setting.json文件
窗口设置
通过坐标 “initialPosition”参数 控制窗口位置。
1 2 3 "initialCols" : 97 , "initialPosition" : "480,250" , "initialRows" : 27 ,
颜色配置
在线预览颜色配置:https://windowsterminalthemes.dev/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 { "background" : "#001B26" , "black" : "#282C34" , "blue" : "#61AFEF" , "brightBlack" : "#5A6374" , "brightBlue" : "#61AFEF" , "brightCyan" : "#56B6C2" , "brightGreen" : "#98C379" , "brightPurple" : "#C678DD" , "brightRed" : "#E06C75" , "brightWhite" : "#DCDFE4" , "brightYellow" : "#E5C07B" , "cursorColor" : "#FFFFFF" , "cyan" : "#56B6C2" , "foreground" : "#DCDFE4" , "green" : "#98C379" , "name" : "One" , "purple" : "#C678DD" , "red" : "#E06C75" , "selectionBackground" : "#FFFFFF" , "white" : "#DCDFE4" , "yellow" : "#E5C07B" }
Profile配置
已实现可视化配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 { "acrylicOpacity" : 0.6 , "backgroundImage" : null , "backgroundImageOpacity" : 0.0 , "bellStyle" : [ "window" , "taskbar" ] , "closeOnExit" : "graceful" , "colorScheme" : "One" , "commandline" : "D:/PowerShell/7/pwsh.exe -nologo" , "cursorColor" : "#AEAFAD" , "cursorShape" : "filledBox" , "font" : { "face" : "CaskaydiaCove NF" , "size" : 10 } , "guid" : "{xxxx-xxxx-xxx-xxx-xxx-xxxx-xxxx}" , "hidden" : false , "historySize" : 9001 , "icon" : "D:\\PowerShell\\7\\assets\\StoreLogo.png" , "name" : "PowerShell" , "padding" : "5" , "snapOnInput" : true , "startingDirectory" : "%USERPROFILE%/Desktop" , "suppressApplicationTitle" : true , "useAcrylic" : true }
字体配置
字体下载:https://www.nerdfonts.com/font-downloads
1 2 Caskaydia Cove Nerd Font Hack Nerd Font
PowerShell 配置 1 2 编辑 profile 文件 code $PROFILE
PSFzf
终端下的文件查找工具
1 Install-Module -Name PSReadLine -Scope CurrentUser
1 2 3 Import-Module -Name PSFzfSet-PSFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r'
PSReadLine
历史命令提示
1 Install-Module -Name PSReadLine -Scope CurrentUser
PS:如果powershell的版本大于等于6,将自动包含最新的PSReadLine,不需要再单独安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 Import-Module PSReadLineSet-PSReadLineOption -PredictionSource History Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackwardSet-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForwardSet-PSReadLineOption -Colors @ { Command = "#e5c07b" Number = "#cdd4d4" Member = "#e06c75" Operator = "#e06c75" Type = "#78b6e9" Variable = "#78b6e9" Parameter = "#e06c75" ContinuationPrompt = "#e06c75" Default = "#cdd4d4" Emphasis = "#e06c75" Selection = "#cdd4d4" Comment = "#cdd4d4" Keyword = "#e06c75" String = "#78b6e9" InlinePrediction = "#9f9193" }
zsh-Autosuggestion除了可以使用→
键补全全部外,还可以使用ctrl + →
选择下一个单词。
1 2 3 Set-PSReadLineKeyHandler -Chord "Ctrl+RightArrow" -Function ForwardWord
ZLocation - 目录跳转
https://github.com/vors/ZLocation
类似于linux下的autojump
1 Install-Module ZLocation -Scope CurrentUser
usage:
Terminal-Icons
https://github.com/devblackops/Terminal-Icons
1 Install-Module -Name Terminal-Icons -Repository PSGallery
1 Import-Module -Name Terminal-Icons
命令行流量代理 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 function SetProxy { Set-Item Env:all_proxy "socks5://127.0.0.1:10808" } function SetClashProxy { Set-Item Env:all_proxy "socks5://127.0.0.1:7890" } function SetBurpProxy { Set-Item Env:http_proxy "http://127.0.0.1:8080" Set-Item Env:https_proxy "http://127.0.0.1:8080" } function UnSetBurpProxy { Remove-Item Env:http_proxy Remove-Item Env:https_proxy } function UnSetProxy { Remove-Item Env:all_proxy }
自定义提示符 starship
starship 安装
scoop install starship
1 2 Invoke-Expression (&starship init powershell)
pshazz
pshazz 安装
scoop install pshazz
1 2 try { $null = gcm pshazz -ea stop; pshazz init 'default' } catch { }
oh-my-posh3
oh-my-posh3 配置
1 2 3 4 Install-Module posh-git -Scope CurrentUserInstall-Module oh -my-posh -Scope CurrentUser
1 2 scoop install oh -my-posh3
自定义 1 2 3 4 5 6 7 8 function prompt { " syyu@win " + "$pwd `n $ " }
winfetch
一款花里胡哨的基本信息查看工具,类似的有 neofetch,screenfetch
Scoop scoop安装 1 2 3 4 Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh' )iwr -useb get.scoop.sh | iex
Note: if you get an error you might need to change the execution policy (i.e. enable Powershell) with
1 Set-ExecutionPolicy RemoteSigned -scope CurrentUser
scoop Usage 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Usage: scoop <command> [<args>] Some useful commands are: alias Manage scoop aliases bucket Manage Scoop buckets cache Show or clear the download cache cat Show content of specified manifest. checkup Check for potential problems cleanup Cleanup apps by removing old versions config Get or set configuration values create Create a custom app manifest depends List dependencies for an app export Exports (an importable) list of installed apps help Show help for a command hold Hold an app to disable updates home Opens the app homepage info Display information about an app install Install apps list List installed apps prefix Returns the path to the specified app reset Reset an app to resolve conflicts search Search available apps status Show status and check for new app versions unhold Unhold an app to enable updates uninstall Uninstall an app update Update apps, or Scoop itself virustotal Look for app's hash on virustotal.com which Locate a shim/executable (similar to 'which' on Linux) Type 'scoop help <command>' to get help for a specific command.
scoop配置指南 见另一篇博客
#TODO
常用快捷键
打开Quake模式
显示/隐藏标题栏,在Quake模式(win + 反引号)也可触发
https://docs.microsoft.com/zh-cn/windows/terminal/panes
Alt + Shift + (+) 水平窗格
Alt + Shift + (-) 垂直窗格
…
and so on …
#TODO
配置文件 Windows Terminal
C:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.WindowsTerminal_xxxxxxxxxxxxx\LocalState\settings.json
#TODO
PowerShell 7
C:\Users\%USERNAME%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 function SetProxy { Set-Item Env:all_proxy "socks5://127.0.0.1:10808" } function SetClashProxy { Set-Item Env:all_proxy "socks5://127.0.0.1:7890" } function SetBurpProxy { Set-Item Env:http_proxy "http://127.0.0.1:8080" Set-Item Env:https_proxy "http://127.0.0.1:8080" } function UnSetBurpProxy { Remove-Item Env:http_proxy Remove-Item Env:https_proxy } function UnSetProxy { Remove-Item Env:all_proxy } Import-Module PSReadLineImport-Module -Name Terminal-Icons Import-Module -Name zSet-PSReadLineOption -PredictionSource History Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackwardSet-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForwardSet-PSReadLineKeyHandler -Chord "Ctrl+RightArrow" -Function ForwardWordSet-PSReadLineOption -Colors @ { Command = "#e5c07b" Number = "#cdd4d4" Member = "#e06c75" Operator = "#e06c75" Type = "#78b6e9" Variable = "#78b6e9" Parameter = "#e06c75" ContinuationPrompt = "#e06c75" Default = "#cdd4d4" Emphasis = "#e06c75" Selection = "#cdd4d4" Comment = "#cdd4d4" Keyword = "#e06c75" String = "#78b6e9" InlinePrediction = "#9f9193" } Invoke-Expression (&starship init powershell)
PowerShell
C:\Users\%USERNAME%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
好了,大致的配置就结束了。
看一波效果图…
还有一些配置和图片,下次一定,先建个#TODO ,哈哈哈哈
参考链接 https://docs.microsoft.com/zh-cn/windows/terminal/
https://juejin.cn/post/6984620463917891614
https://elfile4138.moe/2021/08/Windows-Terminal%E7%9A%84%E9%85%8D%E7%BD%AE/