diff --git a/README.md b/README.md index b6e18c0..a419f5b 100644 --- a/README.md +++ b/README.md @@ -194,10 +194,11 @@ 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. - 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. + 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. ``` ### Aliases diff --git a/vendor/clink.lua b/vendor/clink.lua index 3c4ee42..a05858d 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[30;1m" +end + --- -- Makes a string safe to use as the replacement in string.gsub --- @@ -361,27 +365,29 @@ end --- -- Get the status of working dir --- @return {bool} +-- @return {bool|'branchonly'} --- local function get_git_status_setting() - local gitStatusConfig = io.popen("git --no-pager config cmder.status 2>nul") + 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 @@ -392,7 +398,8 @@ local function git_prompt_filter() local colors = { clean = get_clean_color(), dirty = get_dirty_color(), - conflict = get_conflict_color() + conflict = get_conflict_color(), + unknown = get_unknown_color() } local git_dir = get_git_dir() @@ -403,17 +410,21 @@ local function git_prompt_filter() 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 cmderGitStatusOptIn ~= 'branchonly' then + -- 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 + if gitConflict then + color = colors.conflict + end + else + color = colors.unknown end clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") diff --git a/vendor/cmder_prompt_config.lua.default b/vendor/cmder_prompt_config.lua.default index 5e59c14..5b3068d 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[30;1m"