Skip to content

Instantly share code, notes, and snippets.

@mattn
Created March 23, 2017 07:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattn/7001b16e5b28ae25634ca11185c5bb8e to your computer and use it in GitHub Desktop.
Save mattn/7001b16e5b28ae25634ca11185c5bb8e to your computer and use it in GitHub Desktop.
@echo off
chdir %*
set BRANCH=
for /f "eol=; tokens=1,2 delims== " %%i in ('"git branch 2>NUL"') do if "%%i"=="*" set BRANCH=%%j
if "%BRANCH%" neq "" (
set PROMPT=$P^(%BRANCH%^)$G
) else (
set PROMPT=$P$G
)
rem 設定方法
rem
rem https://mattn.kaoriya.net/software/why-i-use-cmd-on-windows.htm
rem
rem ここ見て init.cmd が使える様にして、init.cmd の中に以下を追加
rem doskey cd=gitcd $*
rem ※ gitcd.bat は本ファイル
@mattn
Copy link
Author

mattn commented Mar 24, 2017

ちなみに git checkout feature でブランチ変えた場合は cd を単にタイプしないとプロンプトは更新されないよ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment