標準の Powershell を Git Shell (Github for Windows) 対応にするメモ
Git の操作は Git Shell でやっているのだけれど、ConEmu に Git Shell の実行パスを入れても新しく Powershell のプロンプトが立ち上がるだけで意味なかった。。
とはいえ、Git Shell も単に Powershell にモジュール入れて起動してるだけっぽいので、自前でそのモジュールをプロファイルに入れてしまえばいいじゃん的な動機です。
Powershell のプロファイルに Git Shell 用の設定をする
上記に書いてあるまんまです。
Powershell のプロファイル C:\Users\<ユーザ>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
に以下を追記するだけらしい。
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1") . $env:github_posh_git\profile.example.ps1
なんとなく内容
.
(ピリオド + 空白) で始めるとドットソース形式での読み込みになるそうです。shell.ps1
をまずは読み込み、その後 profile.example.ps1
を読み込んでるようです。
shell.ps1, profile.example.ps1
この中で github_posh_git
を環境変数に入れています。
$env:github_posh_git = "C:\Users\dan\AppData\Local\GitHub\PoshGit_22f4e7715e1e117547e5dec1ee6c2b8dccaeb2e8"
で、実際そのディレクトリの中に profile.example.ps1
があるという感じですね。
profile.example.ps1
の中では Import-Module .\posh-git
でようやく Git 用のモジュール読み込みをしています。このディレクトリの中はユーティリティ系の powershell ファイルもたくさん入っていて面白そう。
結果
めでたく ConEmu で Powershell を起動するだけで Git Shell の機能が使えるようになりました!