windows terminal加powershell7美化命令行操作

之前写过一篇文章vscode+wsl+windows terminal美化和搭建linux开发环境

wsl挺好用的,不过比较麻烦,而且windows下的liunx子系统不完整,很多东西不能用,毕竟不是虚拟机。看到powershell7,心动了,本篇文章就如标题所言美化命令行操作。

博客链接

下载windows terminal

Microsoft Store就有下载

下载并安装powershell7

选个最新的就行,我下载的是7.1.0-preview3,powershell7下载

下载scoop或者 chocolatey (windows包管理工具)

也可以用powershell的Install-Module,不过还是推荐使用scoop或者chocolatey

scoop为例:

安装scoop

Invoke-Expression (New-Objec System.Net.WebClient).DownloadString('https://get.scoop.sh')
# or
iwr -useb get.scoop.sh | iex

美化powershell

这里主要用到两个包,PSReadLine命令行提示记录,starship美化显示样式,colortool颜色配置

  1. 安装

    Install-Module -Name PSReadLine -AllowPrerelease -Force # PSReadLine
    scoop install colortool
    scoop install starship
    
  2. 写powershell的配置文件

    打开配置文件

    notepad.exe $Profile
    # or 用vscode
    code $Profile
    

    写入

    #-----------------------------------------------------PSReadline
    # 设置 Tab 键补全
    Set-PSReadlineKeyHandler -Key Tab -Function Complete
    
    # 设置 Ctrl+d 为菜单补全和 Intellisense
    # Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete
    
    # 设置 Ctrl+d 为退出 PowerShell
    Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit
    
    # 设置 Ctrl+z 为撤销
    Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
    
    # 设置向上键为后向搜索历史记录
    Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
    
    # 设置向下键为前向搜索历史纪录
    Set-PSReadLineKeyHandler -Key DownArrow -
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值