目录
效果图
下载 Windows Terminal
微软应用商店搜索 Windows Terminal
,第一个应该就是了。
安装 oh-my-posh
管理员权限打开 powershell
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
PS:类似于 oh-my-zsh
设置 settings.json
// This file was initially generated by Windows Terminal 1.4.3243.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// 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}",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": false,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"theme":"dark",
"profiles":
{
"defaults":
{
"cursorShape": "filledBox",
"useAcrylic": true,
"acrylicOpacity": 1,
// "colorScheme": "One Half Dark",
"colorScheme": "Dracula",
// "fontFace": "Cascadia Code PL",
"fontFace": "Sarasa Term SC",
// "startingDirectory": "./"
// Put settings here that you want to apply to all profiles.
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"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.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [
{
"name": "Dracula",
"cursorColor": "#F8F8F2",
"selectionBackground": "#44475A",
"background": "#282A36",
"foreground": "#F8F8F2",
"black": "#21222C",
"blue": "#BD93F9",
"cyan": "#8BE9FD",
"green": "#50FA7B",
"purple": "#FF79C6",
"red": "#FF5555",
"white": "#F8F8F2",
"yellow": "#F1FA8C",
"brightBlack": "#6272A4",
"brightBlue": "#D6ACFF",
"brightCyan": "#A4FFFF",
"brightGreen": "#69FF94",
"brightPurple": "#FF92DF",
"brightRed": "#FF6E6E",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFFA5"
}
],
// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },
// Press Ctrl+Shift+F to open the search box
{ "command": "find", "keys": "ctrl+shift+f" },
// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]
}
配置 $Profile
notepad $Profile
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
# Import-Module posh-git # 引入 posh-git
# Import-Module oh-my-posh # 引入 oh-my-posh
# Set-Theme Paradox # 设置主题为 Paradox
Set-PSReadLineOption -PredictionSource History # 设置预测文本来源为历史记录
Set-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录
右键菜单中添加 Windows Terminal (新版win中已有,无需再添加)
在文件管理器中的当前目录下鼠标右键打开 Windows Terminal。
图标
下载:https://github.com/yanglr/WindowsDevTools/blob/master/awosomeTerminal/icons/wt_32.ico
下载后新建 C:\\Users\\Lenovo\\AppData\\Local\\terminal\\
文件夹,将图标文件 wt_32.ico
放置到这个文件夹下。(Lenovo
是用户名,需替换)
利用注册表添加鼠标右键选项
新建一个注册表文件 terminal.reg
,写入如下内容。(Lenovo
是用户名,需替换)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="C:\\Users\\Lenovo\\AppData\\Local\\terminal\\wt_32.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\Lenovo\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
右键该文件 terminal.reg
,以管理员权限运行。
并在 settings.json 中 profiles
的 defaults
中添加 "startingDirectory": "./"
(上述 settings.json
文件中已添加(现已注释))。
"profiles":
{
"defaults":
{
"startingDirectory": "./"
},
}