Windows Terminal & PowerShell 7 美化

记录一下有关Windows Terminal的折腾记录。

一、最后的成果图

Windows Terminal & PowerShell 7 美化_第1张图片

二、Windows Terminal & PowerShell安装

1.Windows Store 直接搜索进行下载

Windows Terminal & PowerShell 7 美化_第2张图片

2.如果你无法访问 Microsoft Store,GitHub 发布页上发布有内部版本。
3.PowerShell 7.x 下载

PowerShell 下载

4.字体下载
Fira 是 Mozilla 公司主推的字体系列。

Fira Code 是其中的一员,专为写程序而生。

除了具有等宽等基本属性外,还加入了编程连字特性(ligatures)

点击此处下Fira Code

三、Windows Terminal 配置设置

首先附上我自己使用的配置,不要直接复制粘贴 有几处需要改成自己的路径和注意事项,配置文件是以.json结尾的文件类型,建议设置默认打开方式为vscode或者Hbuilder:
Windows Terminal & PowerShell 7 美化_第3张图片

    // This file was initially generated by Windows Terminal 1.1.2233.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": "{90cbdc15-f4fe-49d2-a245-ec066b70845f}",

         //你可以在这里添加更多全局应用程序设置。
         //要了解有关全局设置的更多信息,请访问https://aka.ms/terminal-global-settings
	   

	    //如果启用,选择将自动复制到剪贴板。
	    "copyOnSelect": false,

	    // If enabled, formatted data is also copied to your clipboard
	    "copyFormatting": false,
	    "initialCols": 87, //终端窗口初始宽度
	    "initialRows": 32, //终端窗口初始高



      //配置文件指定要执行的命令,以及关于其外观和感觉的信息。
      //它们中的每一个都将出现在“新标签”下拉列表中,
      //并且可以用` wt.exe -p xxx `从命令行调用
      //要了解有关个人资料的更多信息,请访问https://aka.ms/terminal-profile-settings
	"profiles": {
		"defaults": {
			// Put settings here that you want to apply to all profiles.

			// "acrylicOpacity": 0.8, //背景透明度
			"useAcrylic": false, // 启用毛玻璃
			"fontFace": "Fira Code", //字体
			"fontSize": 13, //文字大小
			"cursorColor": "#FFFFFF", //光标颜色
			"cursorShape": "bar", // 光标形状,可选"bar" ( ┃ )、
            // "vintage" ( ▃ )、"underscore" ( ▁ )、"filledBox" ( █ )、"emptyBox" ( ▯ )
			"cursorColor": "#FFFFFF",
			"colorScheme": "Homebrew",  //设置代码主题颜色  对应下方"schemes" "name"键
			"showTerminalTitleInTitlebar": false,

			"tabWidthMode": "compact",
			"suppressApplicationTitle": true,

			//背景图像设置
			// "backgroundImage": "D:\\Program Files\\PowerShell\\7\\assets\\backimg2.jpg",     
            // 背景图片文件路径,可以是.jpg、.png 或 .gif 文件。


			// "backgroundImageStretchMode" : "uniformToFill"   // 背景图片拉伸模式,
            //可选 "uniformToFill"(默认)、"none"、"fill"、"uniform"

                        //###解开注释的时候每个语句后边都需要使用英文,结尾

			//  "backgroundImageAlignment" : "center" // 背景图像与窗口边界对齐的方式,可选 "center"(默认)
            //"left"、"top"、"right"、"bottom"、"topLeft"、"topRight"、"bottomLeft"、"bottomRight"
			"backgroundImageOpacity": 0.6 // 背景图像不透明度

			//"startingDirectory":"D://Projects//" //起始目录

		},



		"list": [
             {
				"guid": "{90cbdc15-f4fe-49d2-a245-ec066b70845f}",  //guid 唯一标识 可以度娘guid自行生成
				"commandline": "pwsh.exe -nologo ", // 如果已经添加过环境变量可直接使用pwsh.exe  
               //如果没有使用需要添加全路径 格式参照背景图片路径格式
               //-nologo  可以用可不用  不用 启动PowerShell的时候会出现一些提示
				"icon": "D:\\Program Files\\PowerShell\\7\\assets\\Powershell_av_colors.ico",  //设置图标
				"name": "♂☁☁PowerShell 7☁☁", 
				"padding": "10", //内边距
				"snapOnInput": true,
				"startingDirectory": "%USERPROFILE%",
				"hidden": false  //是否隐藏标签

			{
				
                                //在这里更改powershell.exe配置文件。
				"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
				"name": "Windows PowerShell",
				"commandline": "powershell.exe",
				"hidden": true
			},
			{
				// Make changes here to the cmd.exe profile.
				"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
				"name": "♂☁️☁️命令提示符☁️☁️",
				"commandline": "cmd.exe",
				"hidden": false,
				"colorScheme": "Homebrew"
			},
			{
                 //如果没有安装ubuntu 子系统可忽略
				"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
				"hidden": false,
				"name": "♂☁️☁️Ubuntu 20☁️☁️",
				"source": "Windows.Terminal.Wsl",
				"cursorShape": "vintage",
				"colorScheme": "Homebrew"
			},
			{
				"guid": "{0df55b12-ad68-4ab0-9c59-0ef005d38e4b}",
				"commandline": "D:\\Users\\zhiwe\\Scoop\\apps\\git\\2.28.0.windows.1\\bin\\bash.exe", //-nologo
				"icon": "D:\\Users\\zhiwe\\Scoop\\apps\\git\\2.28.0.windows.1\\git.png",
				"name": "♂☁️☁️Git Bash☁️☁️",
				"padding": "10",
				"snapOnInput": true,
				"startingDirectory": "%USERPROFILE%",
				"hidden": false
			},
			{
				"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
				"hidden": false,
				"name": "♂☁☁Azure Cloud Shell☁☁",
				"source": "Windows.Terminal.Azure"
			}

		]
	},

附带自用的几个主题

  	"schemes": [{
			"name": "Homebrew",
			"black": "#000000",
			"red": "#FC5275",
			"green": "#00a600",
			"yellow": "#999900",
			"blue": "#6666e9",
			"purple": "#b200b2",
			"cyan": "#00a6b2",
			"white": "#bfbfbf",
			"brightBlack": "#1487F5",
			"brightRed": "#e50000",
			"brightGreen": "#00d900",
			"brightYellow": "#e5e500",
			"brightBlue": "#409EFF",
			"brightPurple": "#e500e5",
			"brightCyan": "#00e5e5",
			"brightWhite": "#e5e5e5",
			"background": "#283033"
			//前景色
			// "foreground": "#00ff00"

		},
		{
			"name": "MyStyle",
			"background": "#282C34",
			"black": "#282C34",
			"blue": "#409EFF",
			"brightBlack": "#EC7259",
			"brightBlue": "#729fcf",
			"brightCyan": "#56B6C2",
			"brightGreen": "#98C379",
			"brightPurple": "#C678DD",
			"brightRed": "#CB0000",
			"brightWhite": "#DCDFE4",
			"brightYellow": "#E5C07B",
			"cyan": "#56B6C2",
			// "foreground": "#FFFFFF",
			"green": "#4e9a06",
			"purple": "#C678DD",
			"red": "#E06C75",
			"white": "#DCDFE4",
			"yellow": "#E5C07B"

		},
		{
			"name": "Frost",
			"background": "#FFFFFF",
			"black": "#3C5712",
			"blue": "#17b2ff",
			"brightBlack": "#749B36",
			"brightBlue": "#27B2F6",
			"brightCyan": "#13A8C0",
			"brightGreen": "#89AF50",
			"brightPurple": "#F2A20A",
			"brightRed": "#F49B36",
			"brightWhite": "#741274",
			"brightYellow": "#991070",
			"cyan": "#3C96A6",
			"foreground": "#000000",
			"green": "#6AAE08",
			"purple": "#991070",
			"red": "#8D0C0C",
			"white": "#6E386E",
			"yellow": "#991070"
		}

	],

这些是一些命令语法,按需放到配置文件里:

//这些需要写在全局配置里,才会生效
一、打开时的默认终端
"defaultProfile""{uuid}"

二、主题
"theme": "system""dark""light",用"system" 将使用与 Windows 相同的主题,我上面的截图用的是dark暗黑主题。

三、禁用动态配置文件
"disabledProfileSources": ["Windows.Terminal.Wsl", "Windows.Terminal.Azure", "Windows.Terminal.PowershellCore"]

四、选项卡设置
1、始终显示选项卡
"alwaysShowTabs": truefalse
2、选项卡宽度模式
"tabWidthMode": "equal"(等宽)"titleLength"(标题长度)
3、隐藏关闭所有选项卡弹出窗口
"confirmCloseAllTabs": truefalse

五、启动设置
1、以最大化方式启动
"launchMode": "default""maximized"
2、启动位置(窗口左上角的像素位置)
"initialPosition":采用以下格式的字符串形式的坐标:",""X,Y""X,"",Y"
3、首次启动时的列
"initialCols": 整数值
4、首次启动时的行
"initialRows": 整数值

六、标题栏设置
1、显示/隐藏标题栏
"showTabsInTitlebar": truefalse
2、设置标题栏中的文本
"showTerminalTitleInTitlebar": truefalse

七、所选内容设置
1、选择内容后复制
"copyOnSelect": truefalse
2、复制格式
"copyFormatting": truefalse
3、字分隔符
"wordDelimiters": 字符串形式的字符

八、滚动速度
"rowsToScroll": 整数

九、窗口大小调整行为
"snapToGridOnResize": truefalse
// 唯一标识符
    "guid" : "{}",                            // 百度搜uuid生成器,每个终端都要不重复

    // 可执行文件设置
    "commandline" : "D://Git//bin//bash.exe", // 终端的可执行文件路径
    "startingDirectory" : "%USERPROFILE%",    // 加载终端时所处的起始目录

    // 下拉列表设置
    "name" : "Git Bash",                      // 下拉列表中终端的名称
    "icon" : "D://pictures//gitbash.png",     // 下拉列表中终端的图标,填图标路径

    // 文本设置
    "fontFace" : "Consolas",                  // 字体名称。默认Consolas。
    "fontSize" : 11,                          // 字体大小
    "padding" : "0, 0, 0, 0",                 // 填充上下左右的边距
    "antialiasingMode": "grayscale",          // 消除文本锯齿,有 "grayscale"、"cleartype"、"aliased"可选项,具体多大差别我也没看出来

    // Acrylic设置
    "useAcrylic" : true,                      // 使用亚克力效果
    "acrylicOpacity" : 0.75,                  // 亚克力效果不透明度,值越大越不透明

    // 背景颜色
    "background" : "#012456",                 // 背景颜色

    // 滚动设置
    "scrollbarState" : "visible",            // 设置滚动条的可见性("visible"、"hidden")
    "snapOnInput" : true,                    // true:输入时滚动到输入行, false:不滚动
    "historySize" : 9001,                    // 在窗口显示的内容上方可以回滚的行数

    // 光标设置
    "cursorShape" : "bar",                    // 光标形状,可选"bar" ( ┃ )、"vintage" ( ▃ )、"underscore" ( ▁ )、"filledBox" ( █ )、"emptyBox" ( ▯ )
    "cursorColor" : "#FFFFFF",                // 光标的颜色

    // 颜色设置
    "colorScheme" : "Campbell",               // 配色方案名称,默认有"Campbell"、"Campbell Powershell"、"Vintage"、"One Half Dark"、"One Half Light"、"Solarized Dark"、"Solarized Light"、"Tango Dark"、"Tango Light"可选,你也自己可以在下面scheme配置中自己调配配色方案


    // 背景图像设置
    "backgroundImage" : "D://pictures/111.jpg",       // 背景图片文件路径,可以是.jpg、.png 或 .gif 文件。
    "backgroundImageStretchMode" : "uniformToFill",   // 背景图片拉伸模式,可选 "uniformToFill"(默认)、"none"、"fill"、"uniform"
    "backgroundImageAlignment" : "center"             // 背景图像与窗口边界对齐的方式,可选 "center"(默认)、"left"、"top"、"right"、"bottom"、"topLeft"、"topRight"、"bottomLeft"、"bottomRight"
    "backgroundImageOpacity" : 0.75,                  // 背景图像不透明度


    // 退出时配置文件的关闭方式
    "closeOnExit" : true,                    // 设置配置文件如何响应终止或启动失败。 当键入 exit 或进程正常退出时,"graceful" 将关闭配置文件。 "always" 将始终关闭配置文件,而 "never" 将永远不会关闭配置文件。 true 和 false 分别被接受为 "graceful" 和 "never" 的同义词。

    // 怀旧式终端效果**
    "experimental.retroTerminalEffect": false // 设置为 true,则终端将模拟具有扫描线和模糊文本边缘的经典 CRT 显示。 这是一个试验性功能,我们不保证它会持续存在。
一、应用程序级命令(就是terminal这个应用,应用级别的快捷键,好吧,我也不知道怎么解释)
1、关闭应用 
命令名称:closeWindow 
{ "command": "closeWindow", "keys": "alt+f4" }

2、查找
命令名称:find 
{ "command": "find", "keys": "ctrl+f" } 

3、打开下拉菜单
命令名称:openNewTabDropdown
{ "command": "openNewTabDropdown", "keys": "ctrl+shift+space" }

4、打开设置文件
命令名称: openSettings
{ "command": "openSettings", "keys": "ctrl+p" }

5、切换全屏
命令名称: toggleFullscreen
{ "command": "toggleFullscreen", "keys": "alt+enter" },
{ "command": "toggleFullscreen", "keys": "f11" }


二、选项卡相关命令
1、关闭选项卡
命令名称: closeTab
{ "command": "closeTab", "keys": "ctrl+w" }

2、复制选项卡
命令名称: duplicateTab
{ "command": "duplicateTab", "keys": "ctrl+d" }

3、新建选项卡
命令名称: newTab
{ "command": "newTab", "keys": "ctrl+t" },
{ "command": { "action": "newTab", "index": 0 }, "keys": "ctrl+shift+1" },
{ "command": { "action": "newTab", "index": 1 }, "keys": "ctrl+shift+2" },
{ "command": { "action": "newTab", "index": 2 }, "keys": "ctrl+shift+3" },
{ "command": { "action": "newTab", "index": 3 }, "keys": "ctrl+shift+4" },
{ "command": { "action": "newTab", "index": 4 }, "keys": "ctrl+shift+5" },
{ "command": { "action": "newTab", "index": 5 }, "keys": "ctrl+shift+6" },
{ "command": { "action": "newTab", "index": 6 }, "keys": "ctrl+shift+7" },
{ "command": { "action": "newTab", "index": 7 }, "keys": "ctrl+shift+8" },
{ "command": { "action": "newTab", "index": 8 }, "keys": "ctrl+shift+9" },

4、切换选项卡
下一个 命令名称:nextTab
{ "command": "nextTab", "keys": "ctrl+tab" }
上一个 命令名称: prevTab
{ "command": "prevTab", "keys": "ctrl+shift+tab" }
切换指定的选项卡 命令名称: switchToTab
{ "command": { "action": "switchToTab", "index": 0 }, "keys": "ctrl+1" },
{ "command": { "action": "switchToTab", "index": 1 }, "keys": "ctrl+2" },
{ "command": { "action": "switchToTab", "index": 2 }, "keys": "ctrl+3" },
{ "command": { "action": "switchToTab", "index": 3 }, "keys": "ctrl+4" },
{ "command": { "action": "switchToTab", "index": 4 }, "keys": "ctrl+5" },
{ "command": { "action": "switchToTab", "index": 5 }, "keys": "ctrl+6" },
{ "command": { "action": "switchToTab", "index": 6 }, "keys": "ctrl+7" },
{ "command": { "action": "switchToTab", "index": 7 }, "keys": "ctrl+8" },
{ "command": { "action": "switchToTab", "index": 8 }, "keys": "ctrl+9" },


三、窗格相关命令(窗格就是在一个选项卡中再拆分)
1、拆分窗格
命令名称:splitPane
a、自动拆分
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" },
b、水平拆分
{ "command": { "action": "splitPane", "split": "horizontal"}, "keys": "alt+shift+-" }
c、垂直拆分
{ "command": { "action": "splitPane", "split": "vertical"}, "keys": "alt+shift+plus" }

2、关闭窗格
命令名称:closePane
{ "command": "closePane", "keys": "ctrl+shift+w" }

3、移动窗格焦点
命令名称:moveFocus
{ "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+down" },
{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },
{ "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" },
{ "command": { "action": "moveFocus", "direction": "up" }, "keys": "alt+up" },

4、调整窗格大小
命令名称: resizePane
{ "command": { "action": "resizePane", "direction": "down" }, "keys": "alt+shift+down" },
{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+left" },
{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+right" },
{ "command": { "action": "resizePane", "direction": "up" }, "keys": "alt+shift+up" },


四、剪贴板相关命令
1、复制
命令名称: copy
{ "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+c" },

2、粘贴
命令名称: paste
{ "command": "paste", "keys": "ctrl+v" },


五、滚动命令
1、向上滚动
命令名称: scrollUp
{ "command": "scrollUp", "keys": "ctrl+up" },

2、向下滚动
命令名称: scrollDown
{ "command": "scrollDown", "keys": "ctrl+down" },

3、向上滚动一整页
命令名称: scrollUpPage
{ "command": "scrollUpPage", "keys": "pgup" },

4、向下滚动一整页
命令名称: scrollDownPage
{ "command": "scrollDownPage", "keys": "pgdn" },


六、字号调整命令
1、字号大小调整
命令名称: adjustFontSize
{ "command": { "action": "adjustFontSize", "delta": 1 }, "keys": "ctrl+=" },
{ "command": { "action": "adjustFontSize", "delta": -1 }, "keys": "ctrl+-" }
2、重置字号
命令名称: resetFontSize
{ "command": "resetFontSize", "keys": "ctrl+0" }

四、PowerShell 7插件安装

    以管理员身份运行PowerShell 7 中使用命令,需要挂梯子,不然可能会失败!!!!
    #1.允许执行脚本
    set-executionpolicy remotesigned

    # 2. 安装 PSReadline 包
    Install-Module -Name PSReadLine -AllowPrerelease -Force

    # 3. 安装 posh-git 包
    Install-Module posh-git -Scope CurrentUser

    #4. 安装 oh-my-posh 包
    Install-Module oh-my-posh -Scope CurrentUser

    #5.安装Get-ChildItemColor
    Install-Module Get-ChildItemColor

使用notepad $profile 打开用户配置文件 ,在里边添加内容

Import-Module Get-ChildItemColor

Import-Module posh-git

Import-Module oh-my-posh

设置主题

Set-Theme Paradox

使用 Get-Theme 可以查看已安装的主题

Windows Terminal & PowerShell 7 美化_第4张图片

预览主题 永久使用需要在配置文件中修改
Set-Theme 主题名  //预览主题  重启windows terminal 失效

Windows Terminal & PowerShell 7 美化_第5张图片

你可能感兴趣的:(powershell,windows)