diff --git a/vendor/clink.lua b/vendor/clink.lua index 3c4ee42..2110548 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -41,6 +41,10 @@ local function get_conflict_color() return conflict_color or "\x1b[31;1m" end +local function get_unknown_color() + return unknown_color or "\x1b[37;1m" +end + --- -- Makes a string safe to use as the replacement in string.gsub --- @@ -392,34 +396,36 @@ local function git_prompt_filter() local colors = { clean = get_clean_color(), dirty = get_dirty_color(), - conflict = get_conflict_color() + conflict = get_conflict_color(), + nostatus = get_unknown_color() } local git_dir = get_git_dir() + local color cmderGitStatusOptIn = get_git_status_setting() - if cmderGitStatusOptIn then - if git_dir then - -- if we're inside of git repo then try to detect current branch - local branch = get_git_branch(git_dir) - local color - if branch then - -- Has branch => therefore it is a git folder, now figure out status - local gitStatus = get_git_status() - local gitConflict = get_git_conflict() + if git_dir then + local branch = get_git_branch(git_dir) + if branch then + if cmderGitStatusOptIn then + -- if we're inside of git repo then try to detect current branch + -- Has branch => therefore it is a git folder, now figure out status + local gitStatus = get_git_status() + local gitConflict = get_git_conflict() - color = colors.dirty - if gitStatus then - color = colors.clean - end + color = colors.dirty + if gitStatus then + color = colors.clean + end - if gitConflict then - color = colors.conflict - end - - clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") - return false - end - end + if gitConflict then + color = colors.conflict + end + else + color = colors.nostatus + end + clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") + return false + end end -- No git present or not in git file @@ -437,6 +443,7 @@ local function hg_prompt_filter() local colors = { clean = get_clean_color(), dirty = get_dirty_color(), + nostatus = get_unknown_color() } local pipe = io.popen("hg branch 2>&1") @@ -471,6 +478,7 @@ local function svn_prompt_filter() local colors = { clean = get_clean_color(), dirty = get_dirty_color(), + nostatus = get_unknown_color() } if get_svn_dir() then diff --git a/vendor/cmder_prompt_config.lua.default b/vendor/cmder_prompt_config.lua.default index 5e59c14..e5ae224 100644 --- a/vendor/cmder_prompt_config.lua.default +++ b/vendor/cmder_prompt_config.lua.default @@ -43,3 +43,4 @@ lamb_color = "\x1b[1;30;40m" -- Light Grey = Lambda Color clean_color = "\x1b[1;37;40m" dirty_color = "\x1b[33;3m" conflict_color = "\x1b[31;1m" +unknown_color = "\x1b[37;1m" -- White = No VCS Status Branch Color diff --git a/vendor/git-prompt.sh b/vendor/git-prompt.sh index c41a5a1..957dcdc 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[37;1m\]' # change color to white + PS1="$PS1"'`getSimpleGitBranch`' fi fi fi diff --git a/vendor/psmodules/Cmder.ps1 b/vendor/psmodules/Cmder.ps1 index 86dfb02..755d4a7 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 White } return