diff --git a/vendor/clink.lua b/vendor/clink.lua index d69d4e2..5bf3612 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -434,7 +434,6 @@ local function git_prompt_filter() return false end end - end -- No git present or not in git file diff --git a/vendor/git-prompt.sh b/vendor/git-prompt.sh index c41a5a1..ccda575 100644 --- a/vendor/git-prompt.sh +++ b/vendor/git-prompt.sh @@ -9,6 +9,21 @@ function getGitStatusSetting() { fi } +function getSimpleGitBranch() { + gitDir=$(git rev-parse --git-dir 2>/dev/null) + if [ -z "$gitDir" ]; then + return 0 + fi + + headContent=$(< "$gitDir/HEAD") + if [[ "$headContent" == "ref: refs/heads/"* ]] + then + echo " (${headContent:16})" + else + echo " (HEAD detached at ${headContent:0:7})" + fi +} + if test -f /etc/profile.d/git-sdk.sh then TITLEPREFIX=SDK-${MSYSTEM#MINGW} @@ -45,6 +60,9 @@ else . "$COMPLETION_PATH/git-prompt.sh" PS1="$PS1"'\[\033[36m\]' # change color to cyan PS1="$PS1"'`__git_ps1`' # bash function + else + PS1="$PS1"'\[\033[30;1m\]' # change color to gray + PS1="$PS1"'`getSimpleGitBranch`' fi fi fi diff --git a/vendor/psmodules/Cmder.ps1 b/vendor/psmodules/Cmder.ps1 index 86dfb02..5ede0cf 100644 --- a/vendor/psmodules/Cmder.ps1 +++ b/vendor/psmodules/Cmder.ps1 @@ -36,6 +36,14 @@ function checkGit($Path) { if (getGitStatusSetting -eq $true) { Write-VcsStatus + } else { + $headContent = Get-Content (Join-Path $Path '.git/HEAD') + if ($headContent -like "ref: refs/heads/*") { + $branchName = $headContent.Substring(16) + } else { + $branchName = "HEAD detached at $($headContent.Substring(0, 7))" + } + Write-Host " [$branchName]" -NoNewline -ForegroundColor DarkGray } return