且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在PowerShell中为Git分支添加选项卡完成

更新时间:2023-02-02 12:36:42



经过快速搜索之后,类似的东西显然存在,这个怪诞但恰当的命名为posh-git:



http://github.com/dahlbyk/posh-git


一组PowerShell脚本,其中
提供Git / PowerShell集成功能


  • 提示Git仓库:Git仓库中的提示可以显示当前分支和状态
    文件(添加,修改,

    删除) 。
  • 选项卡完成:当
    使用git时,为常用命令提供选项卡完成。例如。 git ch< tab> - >
    git checkout
  • ul>

    用法



    请参阅profile.example.ps1,了解您的
    如何整合制表符完成项目
    和/或git提示到您自己的
    配置文件中。您还可以选择是否在
    标签扩展中显示
    advanced git命令,或者只显示简单/常见
    命令。默认很简单。



When inside a Git repository, is it possible to add tab completion for branches to Powershell? For example:

PS> git checkout maTAB

would result in

PS> git checkout master

For that to be possible, a git provider for PowerShell would need to exist.

After a quick search, something similar apparently exists, the bizarre but aptly named posh-git:

http://github.com/dahlbyk/posh-git

A set of PowerShell scripts which provide Git/PowerShell integration

  • Prompt for Git repositories: The prompt within Git repositories can show the current branch and the state of files (additions, modifications,
    deletions) within.
  • Tab completion: Provides tab completion for common commands when using git. E.g. git ch<tab> --> git checkout

Usage

See profile.example.ps1 as to how you can integrate the tab completion and/or git prompt into your own profile. You can also choose whether advanced git commands are shown in the tab expansion or only simple/common commands. Default is simple.