文本最后编辑时间:2020-06-13

前言

在这之前,我一直使用的都是 cmder,但是这东西说真的,有点难用。不过好在微软推出了 Windows Terminal,经过我的实测,感觉还是不错的。毕竟颜值才是第一生产力。

image-20200604173746487

开始操作

  1. 下载 Windows Terminal

    下载很简单,在微软商店下载即可。

    image-20200604172452842

  2. 安装一个字体,比较推荐的是 Fira Code

    单击此处从 GitHub 下载。

  3. 安装新款 Powershell Core

    首先声明,我们这儿用的 Powershell 与 Windows 自带的 Powershell 是完全不同的两个东西,除了功能相似和名字相同,两者内在已经天差地别。

    Powershell Core 是什么呢?这是伟大的 .Net Core 跨平台战略的一个重要组成部分,微软设想,要让强大的 .Net 在所有平台上通用,让这么强大的 Powershell 在所有平台上都能用,古老的 bash 可以退休了!

    下载地址 (可下载最新版本,不一定要下载图中所示)

    image-20200604172952110

  4. 安装 Powershell 插件

    • PSReadLine

      PSReadLine 是一个由微软发布的用于 PowerShell 的行读取实现,提供了以下功能:

      • 语法着色
      • 简单语法错误通知
      • 良好的多行体验
      • 可自定义的键绑定
      • Cmd 和 Emacs 模式
      • 许多配置选项
      • Bash 样式的补全
      • Bash/zsh 样式的交互式历史记录搜索
      • Emacs yank/kill ring
      • 基于 PowerShell Token 的单词移动和删除
      • 撤销 / 重做
      • 自动保存历史记录,包括在实时会话中共享历史记录
      • 菜单补全、Intellisense

      GitHub 地址:https://github.com/PowerShell/PSReadLine

    • oh-my-posh&posh-git

      类似于 oh-my-zsh,oh-my-posh 为 PowerShell 提供了很多自定义主题和配色,而 posh-git 为 PowerShell 提供了 git 状态显示和命令补全等。

      GitHub 地址:https://github.com/JanDeDobbeleer/oh-my-posh

    看完上边的三个插件介绍,我们来安装这三个插件。

    用管理员模式打开刚装好的新版 powershell,逐行输入命令。

    # 1. 安装 PSReadline 包,该插件可以让命令行很好用,类似 zsh
    Install-Module -Name PSReadLine -AllowPrerelease -Force# 2. 安装 posh-git 包,让你的 git 更好用
    Install-Module posh-git -Scope CurrentUser# 3. 安装 oh-my-posh 包,让你的命令行更酷炫、优雅
    Install-Module oh-my-posh -Scope CurrentUser
    

    image-20200604174115515

    image-20200604174201074

    安装完成

    一定要用刚刚安装的新版的 powershell,安装过程可能过于慢,请耐心等待。

    后面两个包的来源可能不受系统信任,不用管它,如果让你选择是否信任,直接输入 Y 即可。

  5. 编辑 $Profile 文件。

    这个文件类似于 ~/.zshrc,会在 PowerShell 启动的时候自动执行,因此我们在这个文件中加载我们所需的模块。

    • Windows

      notepad.exe $Profile

    • Linux

      nano $Profile

    然后在这个文件中添加如下内容:

    Import-Module posh-git # 引入 posh-git
    Import-Module oh-my-posh # 引入 oh-my-poshSet-Theme Paradox # 设置主题为 ParadoxSet-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
    Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
    Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销
    Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
    Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录
    

    oh-my-posh 提供了 10 款 漂亮 的主题供我们选择。 Agnoster,Avit,Darkblood,Fish,Honukai,Paradox,PowerLine,robbyrussell,Sorin,tehrob

  6. 接下来打开 Windows Terminal

    Windows Terminal 默认为旧版本的 powershell,我们需要把新版本作为默认。

    image-20200604175634559

    修改的内容有三个,如果你不想自己改可以直接将我的粘贴到配置文件(需要注意的是:你的 commandline,如果按照默认路径安装(预览版),那么可以直接复制下边。正式版或者更换了安装位置,那么请手动更改位置。其他信息试自己能力进行修改)。

    // This file was initially generated by Windows Terminal 1.0.1401.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": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",// 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.},"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"},{"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}","hidden": false,"name": "PowerShell","source": "Windows.Terminal.PowershellCore"},{// Powershell 7 配置"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}","hidden": false,"name": "pwsh",// 注意:一定要写上 -nologo,否则开启 powershll 会有一段话输出,很讨厌!// 如果下载的是正是版,那么路径为:C:/Program Files/PowerShell/7/pwsh.exe -nologo"commandline": "C:/Program Files/PowerShell/7-preview/pwsh.exe -nologo","source": "Windows.Terminal.PowershellCore",// 启动菜单一定要设置为 <.>,否则后面重要的一步将会无效!"startingDirectory": ".",// 字体"fontFace": "Fira Code","fontSize": 11,"historySize": 9001,"padding": "5, 5, 20, 25","snapOnInput": true,"useAcrylic": false,// 颜色"colorScheme": "idleToes"}    ]},// Add custom color schemes to this array.// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes"schemes": [{"name": "Zenburn","black": "#4d4d4d","red": "#705050","green": "#60b48a","yellow": "#f0dfaf","blue": "#506070","purple": "#dc8cc3","cyan": "#8cd0d3","white": "#dcdccc","brightBlack": "#709080","brightRed": "#dca3a3","brightGreen": "#c3bf9f","brightYellow": "#e0cf9f","brightBlue": "#94bff3","brightPurple": "#ec93d3","brightCyan": "#93e0e3","brightWhite": "#ffffff","background": "#3f3f3f","foreground": "#dcdccc"},{"name": "PencilDark","black": "#212121","red": "#c30771","green": "#10a778","yellow": "#a89c14","blue": "#008ec4","purple": "#523c79","cyan": "#20a5ba","white": "#d9d9d9","brightBlack": "#424242","brightRed": "#fb007a","brightGreen": "#5fd7af","brightYellow": "#f3e430","brightBlue": "#20bbfc","brightPurple": "#6855de","brightCyan": "#4fb8cc","brightWhite": "#f1f1f1","background": "#212121","foreground": "#f1f1f1"},{"name": "Slate","black": "#222222","red": "#e2a8bf","green": "#81d778","yellow": "#c4c9c0","blue": "#264b49","purple": "#a481d3","cyan": "#15ab9c","white": "#02c5e0","brightBlack": "#ffffff","brightRed": "#ffcdd9","brightGreen": "#beffa8","brightYellow": "#d0ccca","brightBlue": "#7ab0d2","brightPurple": "#c5a7d9","brightCyan": "#8cdfe0","brightWhite": "#e0e0e0","background": "#222222","foreground": "#35b1d2"},{"name": "OneHalfDark","black": "#282c34","red": "#e06c75","green": "#98c379","yellow": "#e5c07b","blue": "#61afef","purple": "#c678dd","cyan": "#56b6c2","white": "#dcdfe4","brightBlack": "#282c34","brightRed": "#e06c75","brightGreen": "#98c379","brightYellow": "#e5c07b","brightBlue": "#61afef","brightPurple": "#c678dd","brightCyan": "#56b6c2","brightWhite": "#dcdfe4","background": "#282c34","foreground": "#dcdfe4"},{"name": "OneHalfLight","black": "#383a42","red": "#e45649","green": "#50a14f","yellow": "#c18401","blue": "#0184bc","purple": "#a626a4","cyan": "#0997b3","white": "#fafafa","brightBlack": "#4f525e","brightRed": "#e06c75","brightGreen": "#98c379","brightYellow": "#e5c07b","brightBlue": "#61afef","brightPurple": "#c678dd","brightCyan": "#56b6c2","brightWhite": "#ffffff","background": "#fafafa","foreground": "#383a42"},{"name": "Material","black": "#212121","red": "#b7141f","green": "#457b24","yellow": "#f6981e","blue": "#134eb2","purple": "#560088","cyan": "#0e717c","white": "#efefef","brightBlack": "#424242","brightRed": "#e83b3f","brightGreen": "#7aba3a","brightYellow": "#ffea2e","brightBlue": "#54a4f3","brightPurple": "#aa4dbc","brightCyan": "#26bbd1","brightWhite": "#d9d9d9","background": "#eaeaea","foreground": "#232322"},{"name": "MaterialDark","black": "#212121","red": "#b7141f","green": "#457b24","yellow": "#f6981e","blue": "#134eb2","purple": "#560088","cyan": "#0e717c","white": "#efefef","brightBlack": "#424242","brightRed": "#e83b3f","brightGreen": "#7aba3a","brightYellow": "#ffea2e","brightBlue": "#54a4f3","brightPurple": "#aa4dbc","brightCyan": "#26bbd1","brightWhite": "#d9d9d9","background": "#232322","foreground": "#e5e5e5"},{"name": "Homebrew","black": "#000000","red": "#FC5275","green": "#00a600","yellow": "#999900","blue": "#6666e9","purple": "#b200b2","cyan": "#00a6b2","white": "#bfbfbf","brightBlack": "#666666","brightRed": "#e50000","brightGreen": "#00d900","brightYellow": "#e5e500","brightBlue": "#0000ff","brightPurple": "#e500e5","brightCyan": "#00e5e5","brightWhite": "#e5e5e5","background": "#283033","foreground": "#00ff00"},{"name": "Breeze","black": "#31363b","red": "#ed1515","green": "#11d116","yellow": "#f67400","blue": "#1d99f3","purple": "#9b59b6","cyan": "#1abc9c","white": "#eff0f1","brightBlack": "#7f8c8d","brightRed": "#c0392b","brightGreen": "#1cdc9a","brightYellow": "#fdbc4b","brightBlue": "#3daee9","brightPurple": "#8e44ad","brightCyan": "#16a085","brightWhite": "#fcfcfc","background": "#31363b","foreground": "#eff0f1"},{"name": "idleToes","black": "#323232","red": "#d25252","green": "#7fe173","yellow": "#ffc66d","blue": "#4099ff","purple": "#f680ff","cyan": "#bed6ff","white": "#eeeeec","brightBlack": "#535353","brightRed": "#f07070","brightGreen": "#9dff91","brightYellow": "#ffe48b","brightBlue": "#5eb7f7","brightPurple": "#ff9dff","brightCyan": "#dcf4ff","brightWhite": "#ffffff","background": "#323232","foreground": "#00ff00"},{"name": "Firewatch","black": "#585f6d","red": "#d95360","green": "#5ab977","yellow": "#dfb563","blue": "#4d89c4","purple": "#d55119","cyan": "#44a8b6","white": "#e6e5ff","brightBlack": "#585f6d","brightRed": "#d95360","brightGreen": "#5ab977","brightYellow": "#dfb563","brightBlue": "#4c89c5","brightPurple": "#d55119","brightCyan": "#44a8b6","brightWhite": "#e6e5ff","background": "#1e2027","foreground": "#9ba2b2"},{"name": "Github","black": "#3e3e3e","red": "#970b16","green": "#07962a","yellow": "#f8eec7","blue": "#003e8a","purple": "#e94691","cyan": "#89d1ec","white": "#ffffff","brightBlack": "#666666","brightRed": "#de0000","brightGreen": "#87d5a2","brightYellow": "#f1d007","brightBlue": "#2e6cba","brightPurple": "#ffa29f","brightCyan": "#1cfafe","brightWhite": "#ffffff","background": "#f4f4f4","foreground": "#3e3e3e"}],// 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"}]
    }
    
    • defaultProfile

      defaultProfile 改为新的 powershell。

      "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
      
    • list

      在 list 中新增一个配置,也就是我们的新版 powershell。

      {// Powershell 7.1.0-preview.2 配置"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}","hidden": false,"name": "pwsh",// 注意:一定要写上 -nologo,否则开启 powershll 会有一段话输出,很讨厌!"commandline": "C:/Program Files/PowerShell/7-preview/pwsh.exe -nologo","source": "Windows.Terminal.PowershellCore",// 启动菜单一定要设置为 <.>,否则后面重要的一步将会无效!"startingDirectory": ".",// 字体"fontFace": "Fira Code","fontSize": 11,"historySize": 9001,"padding": "5, 5, 20, 25","snapOnInput": true,"useAcrylic": false,// 颜色"colorScheme": "idleToes"
      },
      
    • colorScheme

      这个也就是配色。

      {"name": "idleToes","black": "#323232","red": "#d25252","green": "#7fe173","yellow": "#ffc66d","blue": "#4099ff","purple": "#f680ff","cyan": "#bed6ff","white": "#eeeeec","brightBlack": "#535353","brightRed": "#f07070","brightGreen": "#9dff91","brightYellow": "#ffe48b","brightBlue": "#5eb7f7","brightPurple": "#ff9dff","brightCyan": "#dcf4ff","brightWhite": "#ffffff","background": "#323232","foreground": "#00ff00"
      },
      
  7. 配置鼠标右键

    完成上面的操作后,重新打开 Windows Terminal 就会发现模样已经变化了。

    image-20200604180232963

    接下来就是配置鼠标右键了,添加鼠标右键的方式有两种,一种是用脚本,另一种就是改注册表。我本人比较推荐直接使用脚本,毕竟修改注册表有风险。。。

    1. 直接使用脚本

      脚本下载地址:https://github.com/lextm/windowsterminal-shell/

      在 .\install.ps1 后面接参数可以定制你要的效果,该仓库提供了三个效果。如果不加参数,则使用默认效果。该仓库有个好处,那就是可以添加一个右键【以管理员身份在此打开】的选项,简便了不少。

      再次使用管理员模式打开 PowerShell7,然后切换到放 install.ps1 的目录进行安装。我这里使用默认安装。如果你想用其他模式,也可以使用其他模式,看自己心情即可。其他模式请参考项目文档。

      image-20200604180936562

      image-20200604180956425

    2. 修改注册表。

      自行百度

  8. 接下来我们到对应目录点击 pwsh 即可呼唤出新版的 powershell。

问题说明

  1. 实验环境

    VMware 下的 Windows2004 版本

  2. 本文中所使用的文件打包

    https://tzk.lanzous.com/b06lz9sfa
    密码:dkqs

文章作者: Dreamy.TZK

文章链接: https://www.antmoe.com/posts/614360dd/index.html

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 小康博客!

Windows Terminal 使用及美化相关推荐

  1. windows terminal 的强力美化和设置

    什么是windows terminal 新一代的终端窗口,支持cmd,bash,powershell,支持标签页,支持字体,配色,窗口透明度,磨砂玻璃,窗口拆分,环境变量-(应该没了吧)接下来一一讲解 ...

  2. Windows Terminal PowerShell 7 美化

    记录一下有关Windows Terminal的折腾记录. 一.最后的成果图 二.Windows Terminal & PowerShell安装 1.Windows Store 直接搜索进行下载 ...

  3. Windows Terminal修改背景美化

    Termail Windows Termail自推出以来就很受欢迎,无论是开源.现代化界面还是字体渲染.gpu加速以及fluent风格,都很大程度上让Termail成为了当红的windows平台终端模 ...

  4. 告别黑白CMD PowerShell + Windows Terminal 终端美化

    Windows Terminal 只支持 Windows 1903 以上的版本,如果你的电脑未升级,可以退出浏览了. 软件介绍与安装 在微软商店下载下载 PowerShell 和 Windows Te ...

  5. Windows 10 使用 PowerShell 7 + Windows Terminal 及乱码、不显示 python环境问题

    目录 1. Windows Terminal 1.1 安装 Windows Terminal 1.2 安装字体 1.3 配置 Windows Terminal 2. Power Shell 7 2.1 ...

  6. 黑科技抢先尝(续2) - Windows terminal中Powershell Tab的美化全攻略

    温馨提示: 原文中含有一些外部链接,点击全文左下角的"阅读原文"体验会更佳喔~  接着之前的文章 黑科技抢先尝(续) - Windows terminal中WSL Linux 终端 ...

  7. 黑科技抢先尝(续) - Windows terminal中WSL Linux 终端的极简美化指南

    之前,本人写了两篇文章 黑科技抢先尝 | Windows全新终端初体验(附代码Build全过程) 和 程会玩 | 无需自行编译也能玩转 Windows Terminal,介绍了玩转Windows te ...

  8. 搭建最炫酷的 Windows Terminal 全新命令行更新以及美化指南 微软新版终端工具安装美化教程

    Windows发布了最新的Windows Terminal命令行工具,拜托了以前的黑色的边框以及一些缺点,我们先来预览一下效果吧 这是我修改保存之后的命令行工具 不仅可以支持快捷键操作还支持自定义快捷 ...

  9. Windows Terminal美化杂记-Windows Terminal使用与配置

    文章目录 Windows Terminal 前言 原cmd Windows Terminal 安装Terminal 配置 配置代码部分 配置字体部分 配置右键添加 测试常量 命令行中执行 管理员权限运 ...

最新文章

  1. mysql command line client和mysql.exe输入密码后闪退问题解决方法
  2. python 多分类逻辑回归_机器学习实践:多分类逻辑回归(softmax回归)的sklearn实现和tensorflow实现...
  3. java shiro登录实例_Shiro安全框架入门篇(登录验证实例详解与源码)
  4. 微信语音怎么转发给别人听_微信分付怎么邀请别人 微信分付如何才能被邀请开通...
  5. sympy特点及简单使用
  6. winform下拉框模糊查询_WINFORM中的COMBOX模糊查询
  7. HTML页面跳转的5种方法分析介绍
  8. cdr CorelDRAW Graphics Suite 2021 (v23.1.0)
  9. MySQL基础篇(上)
  10. 2021年美容师(初级)报名考试及美容师(初级)模拟考试题
  11. 软件开发通识之一:什么是计算机语言?
  12. 为什么一个盘里的文件夹都不见了,里面一片空白,但那些文件所占的内存却还在的,但好像没被删除
  13. 【新知实验室】TRTC视频会议
  14. Sklearn-preprocessing.scale/StandardScaler/MinMaxScaler
  15. Evaluations
  16. 信息安全管理 读书笔记
  17. 【C语言初学必看】猜数字游戏背后的知识
  18. kubesphere离线安装从入门到放弃
  19. 强化学习+数据库简单小结
  20. 计算机网络-实验5:网络层-IP协议分析

热门文章

  1. linux复制整个目录_如何在Linux中复制整个目录?
  2. Cannot create symlink/symbolic to `xxx': Operation not supported
  3. 2.15范冰增长黑客读书笔记
  4. 谈一谈url实现文件下载
  5. 车载信息系统平台的未来发展
  6. Matlab GUI编程技巧(十二):menu创建菜单或菜单项
  7. 轮播图动画滑动动画效果
  8. xcode升级iOS 16问题与解决方案汇总
  9. jQuery仿天猫完美加入购物车
  10. java多线程学习笔记。