本文主要是介绍工具:如何使用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系统(具体版本未查)。安装前需要开启以下功能:
-
CPU的虚拟机功能,否则在初始化过程会报错;
-
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等工具打开
-
配置参数主要有:
- profiles: 配置每个terminal的guid、路径和颜色背景等等
- schemes: 颜色背景
- keybindings: 快捷键设置
-
本人参数配置情况: 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" }] }
-
PS : 每个人的terminal的GUID都不一样,可以通过使用 在线 UUID生成器完成 Online UUID Generator
-
-
最后完成配置的windows terminal
Windows terminal常用的命令
- 分割屏幕:Alt + shift + d
- 關閉屏幕:Ctrl + shift + w
这篇关于工具:如何使用windows terminal+WSL的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!