【Window开发】设置windows terminal

安装方式

在windows商城里搜索 windows terminal
https://i-blog.csdnimg.cn/blog_migrate/3e8c84e4e703f46463303954e623e24b.png

window cmd

默认情况针对于windows terminal的快捷键为:【可以修改】

SHIFT + ALT + ‘-’ :水平分割
SHIFT + ALT + ‘+’ :垂直分割
CTRL + SHIFT + ‘W’ :关闭此时所处的窗口

修改打开powershell

https://i-blog.csdnimg.cn/blog_migrate/86f99b9f306a42f3716cd3a03cfa5f8a.png

选中后,打开右边操作,里面有一个快捷方式打开JSON文件

https://i-blog.csdnimg.cn/blog_migrate/78e6a5bd987058404e324b069d133183.png

因为这些都是我在ubuntu的快捷方式 所以我就改成一样的 这样下意识好弄些 hhh

安装git posh等

Install-Module -Name PSReadLine -AllowPrerelease -Force # PSReadLine
Install-Module posh-git -Scope CurrentUser # posh-git
Install-Module oh-my-posh -Scope CurrentUser # oh-my-posh

设置posh autosuggestions之类的

notepad.exe $Profile

在里面添加:

Import-Module posh-git # 引入 posh-git
Import-Module oh-my-posh # 引入 oh-my-posh

Set-Theme Paradox # 设置主题为 Paradox

Set-PSReadLineOption -PredictionSource History # 设置预测文本来源为历史记录
 
Set-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录

临时设置主题的话:

Set-PoshPrompt -Theme Paradox

无法识别安装时

问题示例:Install-Module : 找不到与参数名称“AllowPrerelease”匹配的参数。

Did you complete the steps prior to this one? Specifically:

Install-Module -Name PackageManagement -Repository PSGallery -Force
Install-Module -Name PowerShellGet -Repository PSGallery -Force

Then restart shell, Then enter

Install-Module -Name Az.StorageSync -AllowPrerelease -AllowClobber -Force

设置conda环境

conda init powershell

然后这里还需要在主题里进行修改以便他能显示我切换了的环境名如下:

https://user-images.githubusercontent.com/35365764/119246443-31445000-bbb4-11eb-8704-347c0b1560bc.png

主要是要添加东西在你的主题设置文件而不是setting.json,原谅我第一次用真的不知道,但是github上开发这个作者实在是太好了!!!简直太耐心了(现在回看我的问题真的是… 有点傻傻的 hhh)此处贴上Github我在issue上问的地址:https://github.com/JanDeDobbeleer/oh-my-posh/issues/731

首先我用的主题是robbyrussel,主要是ubuntu zsh那边的默认用惯了,然后我没有按照开发者说的建一个自己的主题文件,而是直接修改了原主题文件的设置,这是我的路径:C:\Users\zhangkin\Documents\WindowsPowerShell\Modules\oh-my-posh\3.153.1\themes,建议直接everything搜索:robbyrussel

然后我的修改后的配置是这样的:

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "python",
          "style": "plain",
          "foreground": "#E5E4E2",
          "properties": {
            "prefix": "(",
            "postfix":") ",
            "display_virtual_env": true,
            "display_default": true,
            "display_version": false,
            "display_mode": "always"
          }
        },
        {
          "type": "text",
          "style": "plain",
          "foreground": "#98C379",
          "properties": {
            "prefix": "",
            "text": "\u279C",
            "postfix": ""
          }
        },
        {
          "type": "path",
          "style": "plain",
          "foreground": "#56B6C2",
          "properties": {
            "style": "folder"
          }
        },
        {
          "type": "git",
          "style": "plain",
          "foreground": "#D0666F",
          "properties": {
            "branch_icon": "",
            "display_status": false,
            "prefix": "<#5FAAE8>git:(</>",
            "postfix": "<#5FAAE8>)</>"
          }
        },
        {
          "type": "exit",
          "style": "plain",
          "foreground": "#DCB977",
          "properties": {
            "prefix": "\u2717",
            "display_exit_code": false
          }
        }
      ]
    }
  ],
  "final_space": true
}

整体示意

有高亮、有历史信息、有TAB功能等,主题选的和ubuntu的一样 hhh zsh那边的

https://i-blog.csdnimg.cn/blog_migrate/0f7b1f8521c6090845e15f0161966a0d.png

参考

  1. youtube How to set up an awesome prompt with your Git Branch, Windows Terminal, PowerShell, + Cascadia Code!
  2. 对应youtub的博文
  3. 知乎:给 PowerShell 带来 zsh 的体验
  4. 官方修改powershell的设置网址
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Kin-Zhang

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

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

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

打赏作者

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

抵扣说明:

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

余额充值