提起 windows 下的終端,大家可能都會想到巨難看的 CMD
或者稍好一些的 PowerShell
作爲一個常年使用 windows 系統開發的前端,做夢都想要有一個類似 Mac 或者 Linux 命令行的終端,直到我看到了 windows terminal
先放圖,相比前兩者,高端大氣上檔次有沒有,命令支持也非常豐富
windows terminal
windows terminal 是微軟開源的一個終端解決方案,在微軟應用商店就可以下載安裝
系統要求 windows 10 的 18362.0 版本以上
下載後打開應用,界面還是巨難看,不過 windows terminal 的界面都是可以自定義配置的
打開配置文件,目前還不支持界面配置,所以會看到一個 json文件
配置我們常用的 powershell 界面,下面的 schemes 可以添加主題
在 iterm 的主題列表裏選擇自己喜歡的主題,然後搜索對應的 JSON 配置
將配置粘貼到 schemes 數組中,修改 profiles 中 powershell 的屬性 colorScheme 爲你的主題名即可,更多配置詳情參考文檔
例如我的配置如下
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles": [{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"acrylicOpacity": 0.75,
"useAcrylic": true,
"colorScheme": "Gruvbox Dark"
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [{
"name": "Cobalt Neon",
"black": "#142631",
"red": "#ff2320",
"green": "#3ba5ff",
"yellow": "#e9e75c",
"blue": "#8ff586",
"purple": "#781aa0",
"cyan": "#8ff586",
"white": "#ba46b2",
"brightBlack": "#fff688",
"brightRed": "#d4312e",
"brightGreen": "#8ff586",
"brightYellow": "#e9f06d",
"brightBlue": "#3c7dd2",
"brightPurple": "#8230a7",
"brightCyan": "#6cbc67",
"brightWhite": "#8ff586",
"background": "#142838",
"foreground": "#8ff586"
},
{
"name": "Violet Light",
"black": "#56595c",
"red": "#c94c22",
"green": "#85981c",
"yellow": "#b4881d",
"blue": "#2e8bce",
"purple": "#d13a82",
"cyan": "#32a198",
"white": "#d3d0c9",
"brightBlack": "#45484b",
"brightRed": "#bd3613",
"brightGreen": "#738a04",
"brightYellow": "#a57705",
"brightBlue": "#2176c7",
"brightPurple": "#c61c6f",
"brightCyan": "#259286",
"brightWhite": "#c9c6bd",
"background": "#fcf4dc",
"foreground": "#536870"
},
{
"name": "Gruvbox Dark",
"black": "#1e1e1e",
"red": "#be0f17",
"green": "#868715",
"yellow": "#cc881a",
"blue": "#377375",
"purple": "#a04b73",
"cyan": "#578e57",
"white": "#978771",
"brightBlack": "#7f7061",
"brightRed": "#f73028",
"brightGreen": "#aab01e",
"brightYellow": "#f7b125",
"brightBlue": "#719586",
"brightPurple": "#c77089",
"brightCyan": "#7db669",
"brightWhite": "#e6d4a3",
"background": "#1e1e1e",
"foreground": "#e6d4a3"
}
],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": [
{
"command": "copy",
"keys": ["ctrl+shift+c"]
},
{
"command": "paste",
"keys": ["ctrl+shift+v"]
},
{
"command": "closeTab",
"keys": ["ctrl+w"]
},
{
"command": "scrollDown",
"keys": ["ctrl+j"]
},
{
"command": "scrollUp",
"keys": ["ctrl+k"]
},
{
"command": "scrollDownPage",
"keys": ["ctrl+shift+j"]
},
{
"command": "scrollUpPage",
"keys": ["ctrl+shift+k"]
},
{
"command": "prevTab",
"keys": ["ctrl+left"]
},
{
"command": "nextTab",
"keys": ["ctrl+right"]
}
]
}
全部的配置列表參考:配置列表
快捷鍵配置,*
用數字代替
名稱 | 說明 |
---|---|
newTab | 以第一個命令行配置打開新的標籤頁 |
newTabProfile* | 以第 * 個命令行配置打開新的標籤頁 |
closeTab | 關閉當前標籤頁 |
prevTab | 顯示上一個標籤頁 |
nextTab | 顯示下一個標籤頁 |
scrollUp | 向上滾動一行 |
scrollUpPage | 向上滾動一頁 |
scrollDown | 向下滾動一行 |
scrollDownPage | 向下滾動一頁 |
switchToTab* | 顯示第 * 個標籤頁 |
這裏就已經配置完成了,然後我們配置一下 powershell 的功能
Powershell 配置
powershell 的 git 顯示這裏有兩篇博客描述的比較詳細
將美化進行到底,把 PowerShell 做成 oh-my-zsh 的樣子
Windows Terminal 配置oh-my-posh主題
vim
使用 vim 需要安裝 Git,然後繼續下面的操作
- 打開Git安裝目錄,“C:/Program Files/Git/usr/bin/vim.exe”
- 打開windows Powershell的位置:“C:/Windows/System32/WindowsPowerShell/v1.0”, 在此路徑下添加一個名爲profile.ps1的文件,輸入文本
# There's usually much more than this in my profile!
$SCRIPTPATH = "C:\Program Files\Git\usr\share\vim" # 此行根據$VIMPATH尋找相應vim路徑即可
$VIMPATH = "C:\Program Files\Git\usr\bin\vim.exe" # 此行爲1中vim.exe路徑
Set-Alias vi $VIMPATH
Set-Alias vim $VIMPATH
# for editing your PowerShell profile
Function Edit-Profile
{
vim $profile
}
# for editing your Vim settings
Function Edit-Vimrc
{
vim $home\_vimrc
}
- 管理員運行 powershell,執行下面的命令
$ Set-ExecutionPolicy RemoteSigned
然後就可以使用 vim 了