Window Terminal攻略

介绍

这是我安装完成之后的效果

安装

在安装Windows Terminal之前,需要确保Windows版本号在18362以上。使用搜索功能或访问链接即可到达商店页面。

美化

安装 oh-my-posh, 地址

按照文档的指示,一步一步在Powershell终端执行以下语句:(使用Win-X组合键,选中Powershell)

# 安装posh-git和oh-my-posh
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

# 使用记事本打开PS配置文件(如无则创建该文件)
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE

然后在powershell配置文件中添加如下内容

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme iterm2

修改window teminal配置

其他主题配置可以参考地址

// This file was initially generated by Windows Terminal 1.0.1401.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
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
"colorScheme": "Dracula",
// "backgroundImage": "E:/图片/Neon-Genesis-Evangelion-mech-EVA-Unit-01-Ikari-Shinji-1622285-wallhere.com.jpg",
// "backgroundImageOpacity": 0.5,
// "useAcrylic": true,
// "acrylicOpacity": 0.5,
"fontFace": "DejaVu Sans Mono for Powerline"
},
"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": "命令提示符",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl",
"startingDirectory": "F:/workplace"
},
{
"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",
"background" : "#282A36",
"black" : "#21222C",
"blue" : "#BD93F9",
"brightBlack" : "#6272A4",
"brightBlue" : "#D6ACFF",
"brightCyan" : "#A4FFFF",
"brightGreen" : "#69FF94",
"brightPurple" : "#FF92DF",
"brightRed" : "#FF6E6E",
"brightWhite" : "#FFFFFF",
"brightYellow" : "#FFFFA5",
"cyan" : "#8BE9FD",
"foreground" : "#F8F8F2",
"green" : "#50FA7B",
"purple" : "#FF79C6",
"red" : "#FF5555",
"white" : "#F8F8F2",
"yellow" : "#F1FA8C"
}
],

// Add custom keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
"keybindings":
[
// 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+shift+c" },
{ "command": "paste", "keys": "ctrl+shift+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" }
]
}

其他配置

window 下使用vim

  • 安装vim, 下载地址

  • powershell的配置文件中添加别称

    # 打开配置文件
    notepad.exe $PROFILE
    # 添加下面两行, 将E:\path_to_vim_installed替换为自己的安装地址
    Set-Alias vi E:\path_to_vim_installed\vim.exe
    Set-Alias vim E:\path_to_vim_installed\vim.exe

window下使用 tail命令

# 打开配置文件
notepad.exe $PROFILE
# 添加下列内容,保存
function tail ($filename) {
Get-Content $filename -Wait -Tail 30 -Encoding utf8
}

powershell使用linux风格的快捷键

# 打开powershell配置文件
notepad.exe $PROFILE
# 添加下面一行
Set-PSReadlineOption -EditMode Emacs