From 9df8f1a92ad9b02b851410e0c6aa42aab144ea35 Mon Sep 17 00:00:00 2001 From: Ian Craig Date: Tue, 25 May 2021 17:53:41 -0700 Subject: [PATCH] Revert to boolean, keep branch name when status=false --- README.md | 9 ++++----- vendor/clink.lua | 49 ++++++++++++++++++++++-------------------------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index a419f5b..b6e18c0 100644 --- a/README.md +++ b/README.md @@ -194,11 +194,10 @@ You can write `*.cmd|*.bat`, `*.ps1`, and `*.sh` scripts and just drop them in t ``` [cmder] - status = false # Opt out of Git status for 'ALL' Cmder supported shells. - cmdstatus = false # Opt out of Git status for 'Cmd.exe' shells. - cmdstatus = branchonly # Show branch name in 'Cmd.exe' shells, but don't color according to status (faster) - psstatus = false # Opt out of Git status for 'Powershell.exe and 'Pwsh.exe' shells. - shstatus = false # Opt out of Git status for 'bash.exe' shells. + status = false # Opt out of Git status for 'ALL' Cmder supported shells. + cmdstatus = false # Opt out of Git status for 'Cmd.exe' shells. + psstatus = false # Opt out of Git status for 'Powershell.exe and 'Pwsh.exe' shells. + shstatus = false # Opt out of Git status for 'bash.exe' shells. ``` ### Aliases diff --git a/vendor/clink.lua b/vendor/clink.lua index a05858d..4f12c6c 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -365,29 +365,27 @@ end --- -- Get the status of working dir --- @return {bool|'branchonly'} +-- @return {bool} --- local function get_git_status_setting() - local gitCmdStatusConfig = io.popen("git --no-pager config cmder.cmdstatus 2>nul") - for line in gitCmdStatusConfig:lines() do - if string.match(line, 'false') then - gitCmdStatusConfig:close() - return false - elseif string.match(line, 'branchonly') then - gitCmdStatusConfig:close() - return 'branchonly' - end - end - gitCmdStatusConfig:close() - local gitStatusConfig = io.popen("git --no-pager config cmder.status 2>nul") + for line in gitStatusConfig:lines() do if string.match(line, 'false') then gitStatusConfig:close() return false end end + + local gitCmdStatusConfig = io.popen("git --no-pager config cmder.cmdstatus 2>nul") + for line in gitCmdStatusConfig:lines() do + if string.match(line, 'false') then + gitCmdStatusConfig:close() + return false + end + end gitStatusConfig:close() + gitCmdStatusConfig:close() return true end @@ -404,13 +402,13 @@ local function git_prompt_filter() local git_dir = get_git_dir() 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 - if cmderGitStatusOptIn ~= 'branchonly' 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 = colors.unknown + if branch then + if cmderGitStatusOptIn then -- Has branch => therefore it is a git folder, now figure out status local gitStatus = get_git_status() local gitConflict = get_git_conflict() @@ -423,14 +421,11 @@ local function git_prompt_filter() if gitConflict then color = colors.conflict end - else - color = colors.unknown - end + end - clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") - return false - end - 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