工具:如何使用windows terminal+WSL

2024-04-29 20:04

本文主要是介绍工具:如何使用windows terminal+WSL,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

windows terminal + windows subsystem for Linux

近日在使用Cygwin的时候查到原来 巨硬公司已开发Windows terminal工具combine终端,与此同时,通过安装WSL系统,我们可以在window下直接使用Linux,最后将window下安装具有terminal的所有软件都综合到windows terminal下面。

安装 Windows Subsystem for Linux

  • WSL2是windows开发的无需安装虚拟机且与Windows 10共存的Linux系统,一般需要window 10系统(具体版本未查)。安装前需要开启以下功能:
  1. CPU的虚拟机功能,否则在初始化过程会报错;

  2. windows的WSL功能,Windows features选项打开;

  • 完成上述操作后,可通过Microsoft Store搜索Ubuntu安装Ubuntu 20.04或18.04(可以根据自己的喜好下载)。

  • 下载完成后,启动Ubuntu,会出现initialization状态。在初始完成后需要设置root账户名和密码,设置完成后,Windows电脑即拥有了Linux系统了,它与Windows并存。大部分Linux常用的命令均可以在WSL下使用,可作为新手练习或学习Linux,并且它的崩溃不会影响到Windows系统,本人常用来做一些只有root账户才可以操作的命令,比如删库跑路的 rm -rf /* 命令!!!

  • 配置WSL和配置服务器一样,可以修改.bashrc或.bash_profile文件

安装Windows terminal

Windows terminal是Microsoft出品的工具,在GitHub上已有上千颗star了,它有太多太多功能了,这里我只用来作为综合各个terminal的工具。

  • 同样上Microsoft store下载Windows terminal(稳定版本或者preview版本,看自己需求,推荐下载稳定版本),以关键词“terminal”搜索

  • 安装完成后,配置Windows terminal,配置文件是json文件,可通过notepad等工具打开

    1. 配置参数主要有:

      • profiles: 配置每个terminal的guid、路径和颜色背景等等
      • schemes: 颜色背景
      • keybindings: 快捷键设置
    2. 本人参数配置情况: 1.设置了背景图片;2.设置了背景颜色;3.重新调整了terminal顺序;4.添加了新的terminal

      // This file was initially generated by Windows Terminal 1.2.2381.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",// set default profile: ubuntu"defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",// 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": true,// If enabled, formatted data is also copied to your clipboard"copyFormatting": true,//customize the colors, font and keyboard bindings"wordDelimiters" : " \\()",    // word delimiters for copy and paste "showTabsInTitlebar" : true,"showTerminalTitleInTitlebar" : true,// 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":{"backgroundImage": "C:\\Users\\zouhu\\AppData\\Roaming\\terimal_figure\\goose.png","backgroundImageStretchMode": "uniformToFill","backgroundImageOpacity": 0.6,"background": "#013456","acrylicOpacity": 0.8,"useAcrylic": true,//customize the colors, font and keyboard bindings//"wordDelimiters" : " ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}~?\u2502",//"showTabsInTitlebar" : true,//"showTerminalTitleInTitlebar" : true},"list": [{"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}","hidden": false,"name": "Ubuntu-20.04","source": "Windows.Terminal.Wsl","colorScheme": "Monokai Night"},{"guid": "{60af1884-f8af-11ea-adc1-0242ac120002}","hidden": false,"name": "gdl server","commandline": "powershell.exe ssh zouhua@196.168.106.31","colorScheme": "Monokai Night","icon": "C:\\Users\\zouhu\\AppData\\Roaming\\terimal_figure\\SSH.ico"},{// Make changes here to the powershell.exe profile."guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","name": "Windows PowerShell","commandline": "powershell.exe", "hidden": false,"colorScheme": "Monokai Night"},{// Make changes here to the cmd.exe profile."guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}","name": "Command Prompt","commandline": "cmd.exe","hidden": false,"colorScheme": "Solarized Dark Patched"},{"guid": "{a02de8a8-f4d3-11ea-adc1-0242ac120002}","hidden": false,"name": "git","source": "C:\\Software\\git\\Git\\bin\\bash.exe","colorScheme": "Campbell"},{"guid": "{a7874b94-f4d3-11ea-adc1-0242ac120002}","hidden": false,"name": "cygwin","source": "C:\\Software\\Cygwin\\bin\\mintty.exe","colorScheme": "Monokai Night"},{"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}","hidden": false,"name": "Azure Cloud Shell","source": "Windows.Terminal.Azure","colorScheme": "Monokai Night"}]},// Add custom color schemes to this array.// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes"schemes": [{"name": "Solarized Dark Patched","cursorColor": "#657b83","background": "#002b36","foreground": "#fdf6e3","black": "#073642","blue": "#268bd2","cyan": "#2aa198","green": "#859900","purple": "#d33682","red": "#dc322f","white": "#eee8d5","yellow": "#b58900","brightBlack": "#657b83","brightBlue": "#839496","brightCyan": "#93a1a1","brightGreen": "#586e75","brightPurple": "#6c71c4","brightRed": "#cb4b16","brightWhite": "#fdf6e3","brightYellow": "#657b83"},{"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": "Campbell","cursorColor": "#FFFFFF","selectionBackground": "#FFFFFF","background": "#0C0C0C","foreground": "#CCCCCC","black": "#0C0C0C","blue": "#0037DA","cyan": "#3A96DD","green": "#13A10E","purple": "#881798","red": "#C50F1F","white": "#CCCCCC","yellow": "#C19C00","brightBlack": "#767676","brightBlue": "#3B78FF","brightCyan": "#61D6D6","brightGreen": "#16C60C","brightPurple": "#B4009E","brightRed": "#E74856","brightWhite": "#F2F2F2","brightYellow": "#F9F1A5"}],// 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" },{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+shift+plus" },{ "command": { "action": "splitPane", "split": "horizontal" }, "keys": "alt+shift+-" },//moveFocus{ "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+down" },{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" },{ "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" },{ "command": { "action": "moveFocus", "direction": "up" }, "keys": "alt+up" }, //resizepan { "command": { "action": "resizePane", "direction": "down" }, "keys": "alt+shift+down" },{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+left" },{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+right" },{ "command": { "action": "resizePane", "direction": "up" }, "keys": "alt+shift+up" },//closePane{ "command": "closePane", "keys": "ctrl+shift+w" }]
      }
    3. PS : 每个人的terminal的GUID都不一样,可以通过使用 在线 UUID生成器完成 Online UUID Generator

  • 最后完成配置的windows terminal

Windows terminal常用的命令

  • 分割屏幕:Alt + shift + d
  • 關閉屏幕:Ctrl + shift + w

这篇关于工具:如何使用windows terminal+WSL的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/947029

相关文章

一文详解如何使用Java获取PDF页面信息

《一文详解如何使用Java获取PDF页面信息》了解PDF页面属性是我们在处理文档、内容提取、打印设置或页面重组等任务时不可或缺的一环,下面我们就来看看如何使用Java语言获取这些信息吧... 目录引言一、安装和引入PDF处理库引入依赖二、获取 PDF 页数三、获取页面尺寸(宽高)四、获取页面旋转角度五、判断

Windows环境下解决Matplotlib中文字体显示问题的详细教程

《Windows环境下解决Matplotlib中文字体显示问题的详细教程》本文详细介绍了在Windows下解决Matplotlib中文显示问题的方法,包括安装字体、更新缓存、配置文件设置及编码調整,并... 目录引言问题分析解决方案详解1. 检查系统已安装字体2. 手动添加中文字体(以SimHei为例)步骤

C++中assign函数的使用

《C++中assign函数的使用》在C++标准模板库中,std::list等容器都提供了assign成员函数,它比操作符更灵活,支持多种初始化方式,下面就来介绍一下assign的用法,具有一定的参考价... 目录​1.assign的基本功能​​语法​2. 具体用法示例​​​(1) 填充n个相同值​​(2)

Spring StateMachine实现状态机使用示例详解

《SpringStateMachine实现状态机使用示例详解》本文介绍SpringStateMachine实现状态机的步骤,包括依赖导入、枚举定义、状态转移规则配置、上下文管理及服务调用示例,重点解... 目录什么是状态机使用示例什么是状态机状态机是计算机科学中的​​核心建模工具​​,用于描述对象在其生命

使用Python删除Excel中的行列和单元格示例详解

《使用Python删除Excel中的行列和单元格示例详解》在处理Excel数据时,删除不需要的行、列或单元格是一项常见且必要的操作,本文将使用Python脚本实现对Excel表格的高效自动化处理,感兴... 目录开发环境准备使用 python 删除 Excphpel 表格中的行删除特定行删除空白行删除含指定

深入理解Go语言中二维切片的使用

《深入理解Go语言中二维切片的使用》本文深入讲解了Go语言中二维切片的概念与应用,用于表示矩阵、表格等二维数据结构,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习吧... 目录引言二维切片的基本概念定义创建二维切片二维切片的操作访问元素修改元素遍历二维切片二维切片的动态调整追加行动态

prometheus如何使用pushgateway监控网路丢包

《prometheus如何使用pushgateway监控网路丢包》:本文主要介绍prometheus如何使用pushgateway监控网路丢包问题,具有很好的参考价值,希望对大家有所帮助,如有错误... 目录监控网路丢包脚本数据图表总结监控网路丢包脚本[root@gtcq-gt-monitor-prome

Python通用唯一标识符模块uuid使用案例详解

《Python通用唯一标识符模块uuid使用案例详解》Pythonuuid模块用于生成128位全局唯一标识符,支持UUID1-5版本,适用于分布式系统、数据库主键等场景,需注意隐私、碰撞概率及存储优... 目录简介核心功能1. UUID版本2. UUID属性3. 命名空间使用场景1. 生成唯一标识符2. 数

SpringBoot中如何使用Assert进行断言校验

《SpringBoot中如何使用Assert进行断言校验》Java提供了内置的assert机制,而Spring框架也提供了更强大的Assert工具类来帮助开发者进行参数校验和状态检查,下... 目录前言一、Java 原生assert简介1.1 使用方式1.2 示例代码1.3 优缺点分析二、Spring Fr

Python办公自动化实战之打造智能邮件发送工具

《Python办公自动化实战之打造智能邮件发送工具》在数字化办公场景中,邮件自动化是提升工作效率的关键技能,本文将演示如何使用Python的smtplib和email库构建一个支持图文混排,多附件,多... 目录前言一、基础配置:搭建邮件发送框架1.1 邮箱服务准备1.2 核心库导入1.3 基础发送函数二、