6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git commit し忘れてない?

Posted at

ファイルを書き替えたのにgit commitしてなくてアッー!ってならないように。

function git_status {
   git status 2> $null | ForEach-Object {
      if ( $_ -eq "# Changes not staged for commit:" ) {
         Write-Host "Please run 'git commit'" -ForegroundColor "Red"
      }
   }
}

プロファイルスクリプトのpromptファンクション内でgit_statusを呼び出せばOk。

もう少しマイルドに警告してほしい場合は下記の様にしてもいいかも。
ウィンドウタイトルにアスタリスクを付けるだけの警告です。

function git_status {
   git status 2> $null | ForEach-Object {
      if ( $_ -eq "# Changes not staged for commit:" ) {
         Write-Output "* "
      }
   }
}

promptファンクション内で

$gitstatus = git_status
$windowtitle = (Get-Host).UI.RawUI.WindowTitle
(Get-Host).UI.RawUI.WindowTitle = $gitstatus + $windowtitle

通常のアプリケーションで内容を変更したときなんかと同じ風な警告ですね。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?