Windows Terminal 安装和配置

2023-11-06

参考资料:https://felord.cn/windows-terminal-beautify.html 略有改动

一.下载

2.安装主题

打开PowerShell安装Oh-My-PoshPosh-Git

Set-ExecutionPolicy Bypass
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

Posh-GitGit状态信息添加到提示,并为Git命令、参数、远程和分支名称添加 tab 自动补全。 Oh-My-PoshPowerShell提示符提供主题功能。

如果使用的是PowerShell Core,请安装PSReadline

Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

 然后PowerShell命令行执行:

if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE

 会打开如下记事本,将下面的代码配置到记事本中保存:

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
#Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if(Test-Path($$ChocolateyProfile)){
    Import-Module "$ChocolateyProfile"
}

当然你可以在命令行中执行 Get-Theme 列出所有的样式:

可以set-theme 主题名字 设置主题样式

 3.安装Powerline字体

Powerline提供自定义的命令提示符体验,提供Git状态颜色编码和提示符,不然很多符号都是乱码。

git clone  https://github.com/powerline/fonts.git --depth=1

如果抛出如下异常:

输入以下命令

git config http:postBuffer 524288000
git config http.sslVerify "false"

如果提示: fatal : not in a git  directory

执行:

git init

在输入:

git config http.sslVerify "false"

再输入clone命令就可以了

继续执行命令

cd fonts

./install.sh

 重新以管理员身份运行

PS: 设置打开的此路径下的json 文件

 C:\User/用户名\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

重新建个json副本覆盖原先的json 文件,内容如下

{
    "$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": "Banana Blueberry",
            "background": "#191323", //背景颜色,PS默认为蓝色
            "closeOnExit": true, //关闭窗口的时候退出所有挂载的程序
            "commandline": "powershell.exe", //此处终端打开PS
            "cursorColor": "#FFFFFF", //光标颜色
            "cursorShape": "bar", //光标形状(默认为bar,即条状)
            "fontFace": "DejaVu Sans Mono for Powerline",
            "fontSize": 12,
            "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", //唯一标识符,随机生成
            "historySize": 9001, //缓存大小
            "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png", //图标
            "name": "PowerShell", //在下拉菜单里显示的名称
            "tabTitle": "PowerShell", //在选项卡上显示的名称
            "padding": "0, 0, 0, 0", //内容的边框距,默认填充全部空间
            "snapOnInput": true, //输入的时候自动滚动到输入位置
            "startingDirectory": "%USERPROFILE%" //初始工作目录,默认为用户目录
        },
        "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": "{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": "Monokai Night",
            "background": "#1f1f1f",
            "foreground": "#f8f8f8",
            "black": "#1f1f1f",
            "blue": "#6699df",
            "cyan": "#e69f66",
            "green": "#a6e22e",
            "purple": "#ae81ff",
            "red": "#f92672",
            "white": "#f8f8f2",
            "yellow": "#e6db74",
            "brightBlack": "#75715e",
            "brightBlue": "#66d9ef",
            "brightCyan": "#e69f66",
            "brightGreen": "#a6e22e",
            "brightPurple": "#ae81ff",
            "brightRed": "#f92672",
            "brightWhite": "#f8f8f2",
            "brightYellow": "#e6db74"
        },
        {
            "name": "Banana Blueberry",
            "black": "#17141f",
            "red": "#ff6b7f",
            "green": "#00bd9c",
            "yellow": "#e6c62f",
            "blue": "#22e8df",
            "purple": "#dc396a",
            "cyan": "#56b6c2",
            "white": "#f1f1f1",
            "brightBlack": "#495162",
            "brightRed": "#fe9ea1",
            "brightGreen": "#98c379",
            "brightYellow": "#f9e46b",
            "brightBlue": "#91fff4",
            "brightPurple": "#da70d6",
            "brightCyan": "#bcf3ff",
            "brightWhite": "#ffffff",
            "background": "#191323",
            "foreground": "#cccccc"
        }
    ],
    // 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+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"
        }
    ]
}

更多更详细的内容请参考官网   https://docs.microsoft.com/zh-cn/powershell/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Windows Terminal 安装和配置 的相关文章

  • 如何在 Mac OS X 上以 root 身份运行脚本? [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我应该在 Mac OS X 终端上输入什么才能以 root 身份运行脚本 与任何基于 UNIX 的环境一样 您可以使用sudo http xkcd c
  • Apple 听写 - 在应用程序中使用

    有什么方法可以在本机 Apple 应用程序中利用 Apple 的听写语音转文本功能吗 你的问题有点模糊 最好先知道你尝试使用或做什么 或者你想要实现什么目标 更常见的是关键字识别 API 但可以用于此目的的语音识别 API 是张开耳朵 ht
  • Bash:在新终端中执行带有参数的命令[重复]

    这个问题在这里已经有答案了 所以我想在 bash 中打开一个新终端并执行带参数的命令 只要我只采取类似的东西ls作为命令它工作正常 但是当我采取类似的东西时route n 所以带参数的命令不起作用 代码 gnome terminal win
  • 使用单个 shell 脚本运行 React 和 Flask

    我构建了一个使用 ReactJS 作为前端和 Flask 作为中间件的应用程序 我可以使用以下命令序列来执行它 npm start cd Equation Solver python m flask run 执行第一个命令后 我必须打开另一
  • Windows 终端中的图标和背景图像字段无法识别父进程目录

    Windows 终端版本 1 12 10732 0 Windows 内部版本号 19043 1645 Issue 如果这个问题已经在其他地方得到解决 请原谅我 但我意识到当Use parent process directory被检查 Co
  • 如何永久清除 linux/ubuntu 终端或 bash 中的所有历史记录? [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 当您在 Linux 终端中使用向上键时 可以再次使用之前的命令 很棒的功能 但是 我开始使用命令中的敏感详细信息将 mysql 记录到 mysql 中
  • 安装 oAuth PECL 错误:无法安装,当前用户无法写入频道“pecl.php.net”的 php_dir

    我尝试在 OS X 上安装 oAuth 但在终端中收到此错误 无法安装 当前用户无法写入频道 pecl php net 的 php dir 我如何让它可写 首先找出php dir在哪里 您可以使用 config get 命令来执行此操作 p
  • 箭头键变成 Telnet 中的控制字符

    我在 Ubuntu 终端中 并通过 telnet 连接到服务器 现在每当我输入 up 时 它就会变成 A 其他箭头键也变成控制字符 有没有办法可以运行 telnet 以便它理解我的箭头键 这将是一个巨大的帮助 因为我想在我的命令历史记录中向
  • 如何取消 Postgres 中的错误命令(从终端)?

    我在尝试编写函数时写了一个错误的命令 我在函数中犯了一个错误 并且想在没有完成函数的情况下退出它 并且我想退出它 但是终端的命令提示符不允许我退出 我试过这个 https unix stackexchange com questions 4
  • Linux命令列出所有可用命令和别名

    是否有一个 Linux 命令可以列出该终端会话的所有可用命令和别名 就好像您输入 a 并按下 Tab 键一样 但针对的是字母表中的每个字母 或者运行 别名 但也返回命令 为什么 我想运行以下命令并查看命令是否可用 ListAllComman
  • 如何不断刷新屏幕并实时更新[关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我想在linux上写一个C程序 不断刷新屏幕并实时更新 例如类似于top终端中的命令 谁能指出我正确的方向 为了保持它跨终端类型的可移
  • 给出 5 个参数,但在终端中只得到 3 个参数

    我想将一个文件传递给一个c 程序 如果我在 IDE 中执行此操作 test string string lt test txt return argc 5 但在终端上我刚刚得到argc 3 看来 这是因为 什么是 lt 意思是 我正在使用
  • VS Code 即使关闭也使用 100% CPU

    即使未打开 VS Code 也会占用 100 的 CPU 使用率 我跑了ps aux grep PID命令查看详细信息但什么也看不懂 这是输出 tawhid 27099 100 0 0 1 447352160 11856 R 7 18PM
  • .profile 无法从 Mac 终端运行

    我有一个 profile 文件 我正在终端中读取并使用别名 但在某些时候 别名由于没有明确的原因而停止工作 其他命令仍在工作 为了快速修复 我删除了 rm 并在用户目录中重新创建了 profile 文件 我可以看到 至少在该目录中没有 ba
  • linux命令中括号的用途是什么[重复]

    这个问题在这里已经有答案了 我在 Linux 终端中运行以下命令 谁能告诉我 Linux 终端中括号和以下命令的用途是什么 echo GET HTTP 1 0 echo 主机 www google com echo 数控 www googl
  • SQLite:从命令行仅将模式转储到 .sql 文件中

    我正在尝试转储架构test db仅 即没有数据 到名为的文件中schema sql从 OS X 中的命令行 无需启动 sqlite3 我知道我能做到 sqlite3 open test db output schema sql schema
  • 无需 root 访问权限即可安装 zsh? [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 有可能 以及如何 我确实需要在几台具有 ssh 访问权限 但没有 root 访问权限 的远程计算机上使用此功能 下载 zsh wget O zsh t
  • 如何在 osx 终端中返回应用程序版本

    我需要在 Mac osX 10 10 上的 sh 脚本中使用应用程序版本 以便我可以与另一个数字进行比较 以便我可以强制更新或不更新 到目前为止我已经有了这个 我使用 Firefox app 作为示例 FirefoxmdlsVersion
  • Python 声音(“铃声”)

    我想让一个 python 程序在完成任务时通过发出嘟嘟声来提醒我 目前 我使用import os然后使用命令行语音程序说 进程完成 我更愿意它是一个简单的 铃 我知道有一个函数可以用于Cocoa apps NSBeep 但我认为这与此没有太
  • 使用转义序列渲染文本(如终端)

    你好 我正在寻找一些库或工具来在文本文件中呈现带有转义序列字符的文本 我不知道如何称呼它 但这是一个例子 echo e abc vdef abc def echo e abc vdef gt tmp xxxxx vi tmp xxxxx 我

随机推荐