• 关于使用Windows Terminal命令行/终端多开器


    Windows Terminal 简介

    Windows Terminal is a new, modern, feature-rich, productive terminal application for command-line users. It includes many of the features most frequently requested by the Windows command-line community including support for tabs, rich text, globalization, configurability, theming & styling, and more.

    The Terminal will also need to meet our goals and measures to ensure it remains fast and efficient, and doesn't consume vast amounts of memory or power.

    Windows终端是一个面向命令行工具和 shell(如命令提示符、PowerShell 和适用于 Linux 的 Windows 子系统 (WSL))用户的新式终端应用程序。 它的主要功能包括多个选项卡、窗格、Unicode 和 UTF-8 字符支持、GPU 加速文本呈现引擎,还可以用于创建你自己的主题并自定义文本、颜色、背景和快捷键绑定。

    Windows Terminal 下载/安装

    方式一,如果有Microsoft Store,那就推荐从商店搜索安装

    打开商店,搜索关键词Windows Terminal,即可搜到它,安装即可。

    方式二,直接进Windows Terminal Github Release 页面,下载安装包

    截稿时最新版:Windows Terminal v1.0.1811.0

    官方下载页面:https://github.com/microsoft/terminal/releases

    方式三,如果有Windows Package Manager(winget)也可以直接命令行安装

    winget install --id=Microsoft.WindowsTerminal -e
    

    Windows Terminal 配置

    它的配置,是从打开后,那个下拉小三角的设置项进入的,是一个纯Json形式的Setting.json配置文件。

    也就是说,我们只要修改这个文件,就等于是修改它的配置了。

    在配置中,找到profiles->defaults的节点,把自定义的配置写在里面就行,按Json的节点模式写哈: Key: Value

    启用Windows10 Acrylic半透明效果,并且可设置透明度

    "useAcrylic" : true,
    "acrylicOpacity" : 0.5
    

    启用指定磁盘路径的背景图片,并且可设置图片透明度

    "backgroundImage" : "D:\xxxxxxxxx\wallhaven-59448.jpg",
    "backgroundImageOpacity": 1
    

    官方详细的配置文档

    玩转 Windows Terminal

    添加到右键快捷菜单

    在记事本/VSC中新建文本

    Windows Registry Editor Version 5.00
     ​
     [HKEY_CLASSES_ROOTDirectoryBackgroundshellwt]
     @="Windows Terminal here"
     "Icon"=".../xxxxxxxx/terminal.ico"
     ​
     [HKEY_CLASSES_ROOTDirectoryBackgroundshellwtcommand]
     @="C:\Users\UserName\AppData\Local\Microsoft\WindowsApps\wt.exe"
    

    以上所有路径都要用两个\来表示。

    保存为xxxxxxx.reg,然后运行即可。

    在Windows Terminal中设置Powerline

    安装Posh-Git、Oh-My-Posh

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

    执行以下命令行:

    Install-Module posh-git -Scope CurrentUser
    Install-Module oh-my-posh -Scope CurrentUser
    Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
    

    然后需要修改PowerShell配置文件。

    如果有配置直接执行:

    notepad $PROFILE
    

    如果没有配置,先执行下面命令,再操作上面的

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

    生成之后,这个文件大概的位置在C:UsersxxxxxxxxxxDocumentsWindowsPowerShellMicrosoft.PowerShell_profile.ps1

    编辑这个文件,追加以下命令行:

    Import-Module posh-git
    Import-Module oh-my-posh
    Set-Theme Paradox
    

    接下来,重启Windows Terminal可能会提示没有权限执行ps脚本,开始菜单右键,在Windows PowerShell 管理员模式执行下面命令即可:

    set-executionpolicy remotesigned
    

    再次重启Windows Terminal即可恢复正常。

    安装Cascadia Code编程字体,解决乱符号问题

    经过前面折腾,我们发现命令行有一些乱码,这是因为有些符号是存在字体里面的,我们下载安装一个微软出品的字体,叫Cascadia Code

    官网下载地址:CascadiaCode-2007.01.zip From Github Release Page

    Cascadia Code 项目主页

    下载之后,解压,把ttf文件夹里面的都安装一遍吧,基本上就够了。

    同时去Windows Terminal的Setting中给PowerShell加一个fontFace配置。

    "fontFace": "Cascadia Code PL"
    

    好了,再次重启Windows Terminal,你将看到你梦想的效果了!

    试试git模式,哈哈,效果可以亮虾你。

    开启新终端欢迎词界面

    找到C:UsersxxxxxxxxxxxxDocumentsWindowsPowerShellMicrosoft.PowerShell_profile.ps1这个文件,编辑它。

    准备在它头部插入点啥。

    好啦,来这个网址输入你喜欢的昵称,http://patorjk.com/software/taag/#p=testall&f=Graffiti&t=TaylorShi

    点击Test All,选择你喜欢的风格。

    点击你中意的一项的Select & Copy,然后粘贴到上面那个文件的头部,保存!

    打开一个新的Windows Terminal标签,就可以看到效果。

  • 相关阅读:
    Stupid Tower Defense
    Lifting the Stone
    城市地平线
    BestCoder Sequence
    Miaomiao's Geometry
    Rating
    Turn the pokers
    Peter's Hobby
    HTTP关键词收集
    HTTP出现前的协议
  • 原文地址:https://www.cnblogs.com/craigtaylor/p/13265262.html
Copyright © 2020-2023  润新知