Windows標準のコマンドライン端末(cmd.exe
)では、Git向けにユーザ経験をカスタマイズすることができません。一方、PowerShellを使用しているならラッキーです。
Posh-Git (https://github.com./dahlbyk/posh-git) というパッケージが、強力なタブ補完機能や、リポジトリの状態を把握するのに役立つプロンプト表示を提供しています。
表示は次のようになります。
Windows用のGitHubクライアントをインストールしている場合は、Posh-Gitがデフォルトで含まれています。必要な作業は、 profile.ps1
(通常 C:\Users\<username>\Documents\WindowsPowerShell
に配置されます)に次の内容を追加するだけです。
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
. $env:github_posh_git\profile.example.ps1
Windows用GitHubクライアントのユーザでない場合は、 (https://github.com./dahlbyk/posh-git) からPosh-Gitのリリースをダウンロードし、 WindowsPowershell
ディレクトリに解凍してください。
その後、管理者権限で PowerShell プロンプトを開き、次の操作を行います。
> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
> cd ~\Documents\WindowsPowerShell\posh-git
> .\install.ps1
これで `profile.ps1`ファイルに適切な内容が追加されます。次にプロンプトを開いた時に、 posh-git が有効になります。