Windows Teminal是一款新式、快速、高效、強大的終端應用程序,適用於命令行工具、命令提示符、PowerShell、WSL(Linux子系統)等等的Shell用戶,主要功能包括多選項卡、窗格、Unicode/UTF-8字符支持、GPU 加速文本渲染引擎,以及自定義主題、樣式和配置等等。git
Github地址:https://github.com/microsoft/terminalgithub
官網下載地址:https://www.microsoft.com/zh-cn/p/windows-terminal/9n0dx20hk701?activetab=pivot:overviewtabshell
打開Microsoft Store
,搜索Windows Teminal
並安裝。json
啓動:ubuntu
Widows 10 默認是 Windows PowerShell 是 5.X 版本,在 Win10 V1903 以上版本後,打開 PowerShell 時,會提示 「嘗試新的跨平臺 PowerShell https://aka.ms/pscore6」 ,打開提示網址。windows
下載地址:https://github.com/PowerShell/PowerShell/releasesbash
選擇PowerShell-<version>-win-<os-arch>.msi
格式的安裝包:工具
下載後,雙擊安裝程序並按照提示進行操做。oop
安裝程序在 Windows「開始」菜單中建立一個快捷方式。ui
$env:ProgramFiles\PowerShell\
$env:ProgramFiles\PowerShell\\pwsh.exe
啓動 PowerShellPowerShell 7 安裝到新目錄,並與 Windows PowerShell 5.1 並行運行。 對於 PowerShell Core 6.x,PowerShell 7 是刪除 PowerShell Core 6.x 的就地升級。
$env:ProgramFiles\PowerShell\7
$env:ProgramFiles\PowerShell\7
文件夾已添加到 $env:PATH
$env:ProgramFiles\PowerShell\6
文件夾已刪除若是須要與 PowerShell 7 並行運行 PowerShell 6,請使用 ZIP 安裝方法從新安裝 PowerShell 6。
查看版本,在命令行窗口中輸入命令
$PSVersionTable.PSVersion
參考:https://docs.microsoft.com/zh-cn/windows/terminal/
默認會話爲Power Shell 5.x版本,將之修改成7
"defaultProfile":
的值改成"source": "Windows.Terminal.PowershellCore"
的guid便可,例如它的guid爲"{574e775e-4f2a-5b96-ac1e-a2962a402336}"
。
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
{ "name": "Snazzy", "black": "#000000", "red": "#fc4346", "green": "#50fb7c", "yellow": "#f0fb8c", "blue": "#49baff", "purple": "#fc4cb4", "cyan": "#8be9fe", "white": "#ededec", "brightBlack": "#555555", "brightRed": "#fc4346", "brightGreen": "#50fb7c", "brightYellow": "#f0fb8c", "brightBlue": "#49baff", "brightPurple": "#fc4cb4", "brightCyan": "#8be9fe", "brightWhite": "#ededec", "background": "#1e1f29", "foreground": "#ebece6" }
Github地址:https://github.com/JanDeDobbeleer/oh-my-posh
安裝 posh-git 和 oh-my-posh
Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser Install-Module DirColors
設置 Powershell 的 profile
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force } notepad $PROFILE
粘貼如下內容進 profile 文件
Import-Module posh-git Import-Module oh-my-posh Import-Module DirColors
安裝colortool
scoop install colortool
查看顏色方案
colortool -s
設置顏色:
colortool OneHalfDark.itermcolors
Power Shell 7的配置:
{ "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "PowerShell", "source": "Windows.Terminal.PowershellCore", "colorScheme" : "Snazzy", "startingDirectory": "E:\\", "fontFace" : "Cascadia Code PL", "cursorColor" : "#000000" }
顯示效果以下:
Power Shell 7的配置:
{ "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", "hidden": false, "name": "Ubuntu-20.04", "colorScheme" : "Snazzy", "startingDirectory": "E:\\code", "source": "Windows.Terminal.Wsl" },
修改命令提示符,修改root用戶的~/.bashrc
文件:
export PS1='\[\e[31;1m\][\u\[\e[37;1m\]@\[\e[34;1m\]\H \W]\[\e[35;1m\]\$ \[\e[0m\]'
新建/etc/profile.d/ps1.sh
export PS1='\[\e[36;1m\][\u\[\e[33;1m\]@\[\e[35;1m\]\H \W]\[\e[34;1m\]\$ \[\e[0m\]'
新建/etc/profile.d/alias.sh
alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot' alias xzegrep='xzegrep --color=auto' alias xzfgrep='xzfgrep --color=auto' alias xzgrep='xzgrep --color=auto' alias zegrep='zegrep --color=auto' alias zfgrep='zfgrep --color=auto' alias zgrep='zgrep --color=auto'
顯示效果以下: