Windows下,terminal美化、命令行美化

2021/12/15 7:17:19

本文主要是介绍Windows下,terminal美化、命令行美化,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1. Terminal

terminal 比 原生的 cmd 要更加好用
直接去 Micorosoft Store 下载就行了
image

2. 美化效果图

image

3. 美化步骤

3.1 需要的插件

  • git-aliases
  • posh-git
    前两个组合起来,可以实现类似 oh-my-zsh 一样的 Git增强(命令别名和显示分支等信息)
  • oh-my-posh:terminal的美化主题
  • DirColors:彩色方案,实现类似 Unix 终端一样的多彩颜色

3.2 前提准备

  • 用管理员角色 打开 Windows Terminal

  • 权限设置
    因为执行 Install-Module 会报错以下信息:因为在此系统上禁止运行脚本。
    执行以下命令:

    ## 允许执行脚本
    set-executionpolicy remotesigned
    
  • 下载字体
    oh-my-posh 是基于 Meslo LGM NF 字体设计的,V3 更新后 ,原来可以使用其他等宽字体, 但是更新之后就不好使了。 oh-my-posh 官方推荐使用 Meslo LGM NF字体。
    在这里下载:Meslo LGM NF ---Github

  • 安装字体
    把下载的字体解压,ctrl + a 全选,点击鼠标右键,安装。
    image

3.3 安装模块

##  -Scope CurrentUser:只为当前用户安装
Install-Module git-aliases -AllowClobber -Scope CurrentUser
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
Install-Module DirColors -Scope CurrentUser

3.4 导入模块、设置主题

Import-Module git-aliases
Import-Module posh-git
Import-Module oh-my-posh
Import-Module DirColors
Set-PoshPrompt -Theme iterm2

注:这样只是暂时的,关机后就失效了

3.5 永久配置

## 执行以下代码,获取 配置文件路径
$PROFILE

image
没有这个文件的话,就去这个目录下新建这个文件,输入以下内容

Import-Module git-aliases
Import-Module posh-git
Import-Module oh-my-posh
Import-Module DirColors
Set-PoshPrompt -Theme iterm2

保存退出,之后,就能在每次打开 terminal 时,加载这个配置文件,执行其中的命令

  • 主题预览
    主题预览

3.6 主题颜色美化

3.6.1 安装 scoop

scoop 是 Windows 下的包管理工具,可以理解为 Linux 下的 yum,Ubuntu 的 apt-get

3.6.1.1 安装

iwr -useb get.scoop.sh | iex

image

3.6.1.2 添加仓库

scoop 自带的 main bucket 软件太少,需要添加官方维护的 extras bucket

scoop bucket add extras https://github.com/lukesampson/scoop-extras.git

image

3.6.2 安装 colortool

scoop install colortool

image

image

campbell-legacy.ini
campbell.ini
cmd-legacy.ini
deuteranopia.itermcolors
OneHalfDark.itermcolors
OneHalfLight.itermcolors
solarized_dark.itermcolors
solarized_light.itermcolors
# 设置颜色方案
colortool -b OneHalfDark.itermcolors
colortool -b solarized_dark.itermcolors

image

image

3.6.3 配置文件

按需配置就好了
image

image

image

4. 重启 terminal 验证

image

5. 常用快捷键

分屏快捷键如下:

水平分屏:Alt + Shift + 减号
垂直分屏:Alt + Shift + 加号

切换聚焦的分屏视图:alt + (left/right/up/down)
调节分屏的窗口大小:alt + shift + (left/right/up/down)

缩放当前视图:Ctrl+ 加号/减号 (或者 Ctrl + 鼠标滚轮)

退出分屏:exit
image

6. 重点

遇到问题,多看各个组件的官网,更加容易解决问题



这篇关于Windows下,terminal美化、命令行美化的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程