zoukankan      html  css  js  c++  java
  • 是时候扔掉cmder, 换上Windows Terminal

    作为一个Windows的长期用户,一直没有给款好用的终端,知道遇到了 cmder,它拯救一个习惯用Windows敲shell命令的人。

    不用跟我安利macOS真香!公司上班一直用macOS,一方面确实更加习惯windows下面学习, 另一方面是上课需要Windows QQ共享桌面。

    windows Terminal 1.0发布,那么是时候和 cmder 说再见了。

    不过需要做一些配置和美化。

    美化主题

    • 安装posh-git和oh-my-posh
    > Install-Module posh-git -Scope CurrentUser
    > Install-Module oh-my-posh -Scope CurrentUser
    
    • 启用默认设置
    > Set-Prompt
    
    • 设置主题:
    > Set-Theme Sorin
    

    oh-my-posh 支持十几种主题:

    > Set-Theme
    
    位于命令管道位置 1 的 cmdlet Set-Theme
    请为以下参数提供值:
    name: ?
    
    警告: Theme ? not found. Available themes are:
    
    Name                  Type     Location
    ----                  ----     --------
    Agnoster              Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesAgnoster...
    AgnosterPlus          Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesAgnoster...
    Avit                  Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesAvit.psm1
    Darkblood             Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesDarkbloo...
    Fish                  Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesFish.psm1
    Honukai               Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesHonukai....
    Paradox               Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesParadox....
    Powerlevel10k-Classic Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesPowerlev...
    Powerlevel10k-Lean    Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesPowerlev...
    PowerLine             Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesPowerLin...
    pure                  Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412Themespure.psm1
    robbyrussell          Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412Themes
    obbyrus...
    Sorin                 Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412ThemesSorin.psm1
    tehrob                Defaults C:UsersfnngjDocumentsWindowsPowerShellModulesoh-my-posh2.0.412Themes	ehrob.psm1
    
    • 使用记事本打开PS配置文件(如无则创建该文件)
    > if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force } notepad $PROFILE
    

    随后,在打开的记事本窗口里,在文末加入下面内容,以让Powershell在启动之时应用主题,然后保存。(仅对当前用户生效)

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

    设置字体

    如果你设置的主题出现乱码,可以安装SarasaGothic字体库。

    > scoop bucket add nerd-fonts
    > scoop install SarasaGothic
    

    或者直接到github下载:
    https://github.com/be5invis/Sarasa-Gothic/releases

    然后,将字体库解压 复制到 C:WindowsFont 目录。

    Windows Terminal 设置

    点击 Windows Terminal 向下箭头,选择设置,将会找打开一个配置文件。

    // 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": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        // 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.
                "fontFace": "Sarasa Term Slab SC",  // 选择字体,前面安装的
                "backgroundImage" : "C:/Users/fnngj/Pictures/bg.jpg",  // 设置背景图片
                "backgroundImageOpacity" : 0.9, // 背景图片透明度
                "fontSize" : 16,  // 字体大小
                "foreground": "#76EE00"  //字体颜色
            },
           //...
    

    当然,你也可以在继续安装vim 工具,来更加符合你的 shell习惯。

  • 相关阅读:
    c11---位运算相关
    c10---多文件开发
    C9---include,编译
    c8---递归
    c7---函数
    c6----函数的声明和实现
    c5
    Arm 环境上面libgdiplus的简单安装配置
    批量查找可执行文件目录的简单方法
    Android常用工具类
  • 原文地址:https://www.cnblogs.com/fnng/p/12995528.html
Copyright © 2011-2022 走看看