编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

Windows Terminal 美化(windows cmd美化)

wxchong 2024-07-15 09:58:25 开源技术 9 ℃ 0 评论

我们现在看看效果,喜欢这样的 Windows Terminal 吗? 很早的时候,我就想去改造一下 我的 Windows Terminal 了,奈何 没文化,看到别人好看的 Windows Terminal 只能是 一句 WOCAO。后来也就随意了。谁曾想,今天 在 头条上看到一个改造的视频,跟着做了,哎,成了。特此,我记录一下这里面的一些坑。

Windows Terminal

首先呢,我基本上不会 单独的 去使用 Powershell 或者是 CMD 了,之前可能会去用一下。但是后面多了一个 Windows Terminal ,我就基本上使用这个了。因此,本篇文章的美化,也是针对 Windows Terminal 的。至于 PowerShell 和 CMD 的美化,笔者这里就不说了。

步骤

字体

首先我们需要准备好字体,如果你对于 原版的 字体没意见的话,这一步可以跳过。这里笔者准备的是 Fira Code 字体。这个字体也是 笔者除了 JeBrains Mono 之外最喜欢的英文字体了。我们将这个字体安装一下,除了这个字体之外,还有一款字体大家可是试试看: Source Code Pro 。Windows 字体的安装,笔者就不说了,直接复制到 C:\Windows\Fronts 里面就好了。

安装

Install-Module posh-git
Install-Module oh-my-posh
Set-ExecutionPolicy RemoteSigned
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme PowerLine

我们可以把这个保存为 ps1 脚本文件,直接执行就好了。

这里的 posh-git 其实是需要我们安装 Git , 我觉得,对我这篇文章感兴趣的一定是开发的,开发的应该是用 Git 的,本地是有 Git 环境的,你要是用的 svn , 那就劳烦你 安装一下,避免后续的错误。

我们在执行 Install-Module 的时候,可能出现: xxxx/v2 , 意思就是这个接口 连接不上。笔者的原因是 因为开了代理,把代理关了就好

到此,我们的安装就好了,接下来就是主题的美化了。这里,笔者将这个主题的配置也放出来:

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "copyOnSelect": false,
    "copyFormatting": false,
    "profiles":
    {
        "defaults":
        {
            "closeOnExit" : true, // 输入exit退出命令窗口
            "padding" : "0, 0, 0, 0", // 内容距离界面的内部距离
            "snapOnInput" : true, // 嗅探输入
            "historySize" : 9001, // 历史大小
            "antialiasingMode" : "cleartype", // 抗锯齿模式
            "altGrAliasing" : true, // 别名
            "useAcrylic" : true, // 毛玻璃特效
            "acrylicOpacity": 0.25, // 不透明度
            "cursorColor" : "#E6FF00", // 光标颜色
            "cursorShape" : "bar", // 光标类型
            "fontFace" : "Fira Code", // 字体名称
            "fontSize" : 11, // 字体大小
            "hidden": false,
            "tabTitle" : "默认窗体", //标签名称,
            "alwaysShowTabs": true
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "colorScheme" : "Ubuntu", // 主题
                "icon" : "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\powershell.png", // 图标
                "backgroundImage": "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\colorful.jpg", // 背景图片
                "backgroundImageOpacity": 0.5, // 背景图片的不透明度
                "tabTitle" : "Windows PowerShell", //标签名称
                "startingDirectory" : "D:\\" // 起始文件夹路径
            },
            {
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "命令提示符",
                "commandline": "cmd.exe",
                "colorScheme" : "Ubuntu", // 主题
                "icon" : "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\cmd.jpg", // 图标
                "backgroundImage": "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\colorful.jpg", // 背景图片
                "backgroundImageOpacity": 0.5, // 背景图片的不透明度
                "tabTitle" : "CMD", //标签名称
                "startingDirectory" : "D:\\" // 起始文件夹路径
            },
            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl",
                "colorScheme" : "Ubuntu", // 主题
                "icon" : "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\ubutun.jpg", // 图标
                "backgroundImage": "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\colorful.jpg", // 背景图片
                "backgroundImageOpacity": 0.5, // 背景图片的不透明度
                "tabTitle" : "Ubuntu", //标签名称
                "startingDirectory" : "//wsl$/Ubuntu-20.04/home/sunyang" // 起始文件夹路径
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure",
                "colorScheme" : "Ubuntu", // 主题
                "icon" : "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\cloud.jpg", // 图标
                "backgroundImage": "C:\\Users\\sunya\\Pictures\\WindowsTerminal\\colorful.jpg", // 背景图片
                "backgroundImageOpacity": 0.5, // 背景图片的不透明度
                "tabTitle" : "Azure Cloud" //标签名称
            }
        ]
    },
    "schemes": [
        {
            "name": "Ubuntu",
            "black": "#2e3436",
            "red": "#cc0000",
            "green": "#4e9a06",
            "yellow": "#c4a000",
            "blue": "#3465a4",
            "purple": "#75507b",
            "cyan": "#06989a",
            "white": "#d3d7cf",
            "brightBlack": "#555753",
            "brightRed": "#ef2929",
            "brightGreen": "#8ae234",
            "brightYellow": "#fce94f",
            "brightBlue": "#729fcf",
            "brightPurple": "#ad7fa8",
            "brightCyan": "#34e2e2",
            "brightWhite": "#eeeeec",
            "background": "#300a24",
            "foreground": "#eeeeec"
          }
    ],
    "actions":
    [
        { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        { "command": "paste", "keys": "ctrl+v" },
        { "command": "find", "keys": "ctrl+shift+f" },
        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
    ]
}

总结

不信吗?不信你试试

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表