terminal。自定义图_如何自定义新的Windows Terminal应用程序

本文介绍了如何自定义Windows Terminal,包括如何更改背景,使用JSON编辑器调整设置,设置动画GIF背景,更改默认键绑定以及切换配色方案。现在,你可以根据个人喜好深度定制你的Windows Terminal应用。
摘要由CSDN通过智能技术生成
terminal。自定义图

terminal。自定义图

Windows Terminal with an background showing an ocean wave

With the new Windows Terminal app, Windows now finally has a tabbed terminal that can run Cmd, PowerShell, and Bash prompts in the same window. It’s deeply customizable, too—you can even set animated GIFs as the background.

借助新的Windows Terminal应用程序 ,Windows现在终于有了一个选项卡式终端,可以在同一窗口中运行Cmd,PowerShell和Bash提示 。 它也可以深度自定义-您甚至可以将动画GIF设置为背景。

Beyond the background, you can change the terminal’s theme, too. Whether it’s the colors of the text or backgrounds or the font style, you can make Windows Terminal your own. Microsoft even included several pre-set themes. All you need is a text editor and some basic familiarity with JSON. If you aren’t familiar with JSON, you can probably still make changes; we’ll walk you through it.

除了背景之外,您还可以更改终端的主题。 无论是文本的颜色,背景的颜色还是字体的样式,您都可以将Windows Terminal设置为自己的。 微软甚至包括几个预设的主题。 您所需要的只是一个文本编辑器,并且对JSON有一些基本的了解。 如果您不熟悉JSON,则可能仍可以进行更改。 我们将引导您完成。

如何自定义Windows终端 (How to Customize the Windows Terminal)

Windows terminal json configuration file, showing a custom background option.

The first step to customizing Windows Terminal is to ensure Windows has default app associated with the JSON file type. The best way to do that is from File Explorer.

定制Windows Terminal的第一步是确保Windows具有与JSON文件类型关联的默认应用程序。 最好的方法是从文件资源管理器。

Launch File Explorer and find a JSON file. If you don’t have one, create one. Right-click on File Explorer and “New” then click on “Text document.”

启动文件资源管理器并找到一个JSON文件。 如果您没有,请创建一个。 右键单击“文件资源管理器”,然后单击“新建”,然后单击“文本文档”。

Rename the file to test.json (deleting the .txt extension in the process), and confirm you want to change the extension. If you don’t see the .txt file extension, tell File Explorer to show file extensions.

将文件重命名为test.json(在此过程中删除.txt扩展名),并确认您要更改扩展名。 如果您没有看到.txt文件扩展名,请告诉File Explorer显示文件扩展名

File explorer submenu with arrows pointing to New and Text Document

Next, right-click on the new JSON file and choose the “Open With” option. Choose your preferred text editor, whether that be Notepad++ or Notepad.

接下来,右键单击新的JSON文件,然后选择“打开方式”选项。 选择您首选的文本编辑器,无论是Notepad ++还是Notepad。

Now that you have a text editor set for JSON files, it’s time to make changes to Windows Terminal settings. Open Windows Terminal and click on the down arrow in the title bar (just to the right of the plus symbol), and then choose “Settings.”

现在您已经为JSON文件设置了文本编辑器,是时候更改Windows Terminal设置了。 打开Windows终端,然后单击标题栏中的向下箭头(恰好在加号的右边),然后选择“设置”。

Windows terminal with arrows pointing to Down arrow and Settings options.

A JSON file will launch in the editor you choose earlier. You can make all changes here.

JSON文件将在您之前选择的编辑器中启动。 您可以在此处进行所有更改。

如何更改背景 (How to Change the Background)

Windows终端,猫在键盘背景上打字gif
()

You can change the background to any type of image file you like—a PNG, a JPEG, or even an animated GIF.

您可以将背景更改为您喜欢的任何类型的图像文件-PNG,JPEG或动画GIF。

To change the background of any of the shells, you’ll first need to place the image file in a location the Terminal App can read. Windows Terminal is a Univeral Windows Platform (UWP) app, so it prefers to use its own AppData folder. AppData is a folder you usually find in the User Profile and is used for storing program settings. UWP apps create a custom AppData folder and use that instead. Windows Terminal’s AppData folder is located in:

要更改任何外壳的背景,首先需要将图像文件放置在Terminal App可以读取的位置。 Windows Terminal是通用Windows平台(UWP)应用程序,因此它更喜欢使用自己的AppData文件夹 。 AppData是您通常在用户配置文件中找到的文件夹,用于存储程序设置。 UWP应用程序将创建一个自定义AppData文件夹,并使用该文件夹。 Windows Terminal的AppData文件夹位于:

%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState

Just copy that into File Explorer’s path bar and hit Enter; you’ll be taken to the correct location. Place your image files here, and Windows Terminal can use them for backgrounds.

只需将其复制到File Explorer的路径栏中,然后按Enter; 您将被带到正确的位置。 将图像文件放在此处,Windows Terminal可以将它们用作背景。

Providing a background image for Windows Terminal

Open Settings in Windows Terminal, and scroll to the profile you want to change. There are several profiles under the ”  "profiles" : ” section. Each corresponds to an option in the menu: Cmd, PowerShell, Linux distros, and so on. You can tell which is which by examining the ” commandline ” or ” name ” line in each section.

在Windows终端中打开“设置”,然后滚动到要更改的配置文件。 “ "profiles" : “”部分下有多个个人"profiles" : 。 每个对应于菜单中的一个选项:Cmd,PowerShell,Linux发行版等。 通过检查每个部分中的“ commandline ”或“ name ”行,您可以确定哪个是哪个。

To change the background image for one of these sections, under the "icon" line, add the following lines:

要更改这些部分之一的背景图像,请在"icon"行下添加以下行:

"backgroundImage" : "ms-appdata:///roaming/yourimage.jpg",
"backgroundImageOpacity" : 0.75,
"backgroundImageStretchMode" : "fill",

Where “yourimage.jpg” is the name of your image or gif file. Make sure every line in the section—except the last one—ends with a comma.

其中“ yourimage.jpg”是图像或gif文件的名称。 确保本节中的每一行(最后一行除外)都以逗号结尾。

If you’re using a GIF file, you may want to change the “fill” to “uniformToFill” instead. We ended up with a black box around our GIF with “fill,” but it was fine with “uniformToFill.”

如果您使用的是GIF文件,则可能需要将“填充”更改为“ uniformToFill”。 我们最终在GIF周围有一个黑框,显示为“填充”,但使用“ uniformToFill”就可以了。

Setting a background image in Windows Terminal's JSON file

Save the file, and your changes should show up immediately, even with the Windows Terminal open.

保存文件,即使打开Windows终端,更改也应立即显示。

如何更改默认键绑定 (How to Change Default Key Bindings)

The first section pertains key bindings if you don’t like a particular keyboard shortcut you can change those here. For instance, if you want Ctrl+e to close tabs, you would find this section:

如果您不喜欢特定的键盘快捷键,则可以在此处更改键绑定。 例如,如果要Ctrl + e关闭选项卡,则会找到以下部分:

{
 "command" : "closeTab",
 "keys" : 
 [
 "ctrl+w"
 ]
 },


Change the “ctrl+w” to “ctrl+e” (being sure to keep the quotes) and then save the file. If you want to align everything to match the existing indentation, be aware the file uses spaces instead of tabs. And as seen in our screenshots, the file uses Unix Line Endings, but most text editors (even Notepad) can handle Unix Line Endings without issue.

将“ ctrl + w”更改为“ ctrl + e”(确保保留引号),然后保存文件。 如果要对齐所有内容以匹配现有的缩进,请注意文件使用空格而不是制表符。 正如我们的屏幕快照所示,该文件使用Unix Line Endings,但是大多数文本编辑器( 甚至Notepad )都可以毫无问题地处理Unix Line Endings。

Windows terminal key binding options.

如何切换默认配色方案 (How to Switch the Default Color Scheme)

Windows Terminal comes with several color schemes that change the font color, background color, cursor shape, and so on. You can choose themes individually for Command Prompt, Bash, and PowerShell.

Windows Terminal附带了几种颜色方案,这些方案可更改字体颜色,背景颜色,光标形状等。 您可以分别为命令提示符,Bash和PowerShell选择主题。

To switch the default theme, first, find the shell profile you want to by scrolling down to the ” "profiles" :  ” section and looking at the command line entry in each subsection.

要切换默认主题,首先,通过向下滚动到“ "profiles" : “部分并在每个小节中查看命令行条目,找到所需的shell配置文件。

Command Prompt is found under: "commandline" : "cmd.exe", for instance. Then change the "colorScheme" : "Campbell"  to the color of your choice. You can choose from Campbell, One Half Dark, One Half Light, Solarized Dark, and Solarized Light. If you wanted Solarized Light, for example, you would change the color scheme line to "colorScheme" : "Solarized Light. These are the same color schemes used by Microsoft’s colortool utility.

例如,命令提示符位于: "commandline" : "cmd.exe"下。 然后将"colorScheme" : "Campbell"更改为您选择的颜色。 您可以选择“坎贝尔”,“一半暗”,“一半光”,“日光暗”和“日光”。 例如,如果您要使用Solarized Light,则可以将配色方案行更改为"colorScheme" : "Solarized Light 。这些与Microsoft的colortool实用程序使用的配色方案相同。

Windows terminal color scheme option for cmd.exe.


Windows Terminal is pretty interesting, and it gives you a small taste of Microsoft’s former Windows Sets feature. The tabbed functionality here isn’t as robust, but it’s a hint at what could have been. At the very least, now you won’t need to switch programs to move between Command Prompt, Powershell, and Bash.

Windows Terminal非常有趣,它使您对Microsoft以前的Windows Sets功能有所了解。 这里的选项卡式功能不那么健壮,但这暗示了可能的情况。 至少,现在您无需切换程序即可在命令提示符,Powershell和Bash之间移动。

翻译自: https://www.howtogeek.com/426346/how-to-customize-the-new-windows-terminal-app/

terminal。自定义图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值