工具:如何使用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
  • 17
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
当谈到美化和搭建Linux开发环境时, VS Code,WSLWindows Terminal都是非常有用的工具。 首先,VS Code是一款流行的开源代码编辑器,可通过安装各种插件进行美化。你可以选择喜欢的主题和语法高亮方案,以配合你的个人喜好。 其次,WSLWindows Subsystem for Linux)是一种在Windows上运行Linux二进制文件的兼容层。通过安装WSL,你可以在Windows使用真正的Linux发行版,如Ubuntu或Debian。这样,你就可以在Windows系统中体验和开发Linux环境下的应用程序。 最后,Windows TerminalWindows新的命令行终端。它支持多个选项卡以及各种自定义设置,如调整配色方案、字体大小和字体类型等。你可以使用Windows Terminal将多个终端会话放置在一个窗口中,从而提高工作效率。 要搭建Linux开发环境,首先你需要安装WSL以及喜欢的Linux发行版。然后,你可以通过安装VS Code插件和扩展来优化你的开发体验。安装一些常用的扩展,如Python、C++或Node.js,以根据你的需求进行开发。 当你需要在Windows环境中执行Linux命令时,你可以打开Windows Terminal,并选择WSL作为默认终端。这样,你就可以通过Windows Terminal运行和管理你的Linux环境。 总结起来,VS Code,WSLWindows Terminal是一些功能强大且易于使用工具,它们可以帮助你美化和搭建Linux开发环境。使用这些工具,你可以在Windows中轻松进行Linux开发,并以最佳方式执行命令和编辑代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

生信学习者2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值