Skip to content

Instantly share code, notes, and snippets.

@gh640
Created February 6, 2016 08:14
Show Gist options
  • Select an option

  • Save gh640/ec315d5ad0835842c5ea to your computer and use it in GitHub Desktop.

Select an option

Save gh640/ec315d5ad0835842c5ea to your computer and use it in GitHub Desktop.
Bash PS1 for Git repository
# Show Git branch name and number of changed files
# if current directory is in Git repo.
# カレントディレクトリが Git リポジトリの場合に
# 現在のブランチと変更ファイルの数を表示する形にコマンドプロンプトをカスタマイズする
if [ $TERM == xterm ]; then
PS1='\[$(tput setaf 4)\]\u:\W\$\[$(tput sgr0)\]$(if git status &>/dev/null;then echo \[$(tput setaf 5)\][$(git branch | grep ^\* | cut -d " " -f 2) changed:$(git status -s | wc -l)]\[$(tput sgr0)\];fi) '
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment