前提
フォントは CaskaydiaCove NF Mono を使用。
使用したい記号とかを検索するなら Nerd Fonts から検索できる
どちらも、Gitがインストール済みであることを前提としている
Bash
.bashrc
に追記
if [ -f ~/.git-completion.sh ]; then source ~/.git-completion.sh fi if [ -f ~/.git-prompt.sh ]; then source ~/.git-prompt.sh fi GIT_PS1_SHOWDIRTYSTATE=true GIT_PS1_SHOWUNTRACKEDFILES=true GIT_PS1_SHOWSTASHSTATE=true GIT_PS1_SHOWUPSTREAM=auto PS1='\[\e[44m\] \u \[\e[34;49m\]\[\e[37;49m\]\[\e[30;47m\] \t \[\e[0;37m\]\[\e[36m\]\[\e[30;46m\] \w \[\e[0;36m\] \[\e[0m\]$(__git_ps1 "\[\e[33;49m\]\[\e[30;43m\] %s \[\e[33;49m\]")\[\033[00m\]\n '
PowerShell
$profile
に追記
function prompt { $promptSymbol = "$("") " $user = $env:UserName $time = Get-Date -Format "HH:mm" $workingDirectory = Get-Location $gitBranch = "" $gitStatus = "" if (Test-Path ".git") { $gitBranch = & git rev-parse --abbrev-ref HEAD $gitStatus = & git status --porcelain --untracked-files=no | Measure-Object | Select-Object -ExpandProperty Count } if ($gitStatus -eq 0) { $gitStatusSymbol = " $gitBranch" } else { $gitStatusSymbol = " $gitBranch +$gitStatus" } Write-Host -NoNewline -ForegroundColor White -BackgroundColor Blue " $user" Write-Host -NoNewline -ForegroundColor Blue "" Write-Host -NoNewline -ForegroundColor White "" Write-Host -NoNewline -ForegroundColor Black -BackgroundColor White "$time" Write-Host -NoNewline -ForegroundColor White "" Write-Host -NoNewline -ForegroundColor Cyan "" Write-Host -NoNewline -ForegroundColor Black -BackgroundColor Cyan "$workingDirectory" Write-Host -NoNewline -ForegroundColor Cyan "" if (Test-Path ".git") { Write-Host -NoNewline -ForegroundColor Yellow " " Write-Host -NoNewline -ForegroundColor Black -BackgroundColor Yellow " $gitStatusSymbol " Write-Host -NoNewline -ForegroundColor Yellow "" } Write-Host " " " " }