Revert to boolean, keep branch name when status=false

This commit is contained in:
Ian Craig 2021-05-25 17:53:41 -07:00
parent c262934822
commit 9df8f1a92a
2 changed files with 26 additions and 32 deletions

View File

@ -194,11 +194,10 @@ You can write `*.cmd|*.bat`, `*.ps1`, and `*.sh` scripts and just drop them in t
``` ```
[cmder] [cmder]
status = false # Opt out of Git status for 'ALL' Cmder supported 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 = 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.
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.
shstatus = false # Opt out of Git status for 'bash.exe' shells.
``` ```
### Aliases ### Aliases

49
vendor/clink.lua vendored
View File

@ -365,29 +365,27 @@ end
--- ---
-- Get the status of working dir -- Get the status of working dir
-- @return {bool|'branchonly'} -- @return {bool}
--- ---
local function get_git_status_setting() 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") local gitStatusConfig = io.popen("git --no-pager config cmder.status 2>nul")
for line in gitStatusConfig:lines() do for line in gitStatusConfig:lines() do
if string.match(line, 'false') then if string.match(line, 'false') then
gitStatusConfig:close() gitStatusConfig:close()
return false return false
end end
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() gitStatusConfig:close()
gitCmdStatusConfig:close()
return true return true
end end
@ -404,13 +402,13 @@ local function git_prompt_filter()
local git_dir = get_git_dir() local git_dir = get_git_dir()
cmderGitStatusOptIn = get_git_status_setting() cmderGitStatusOptIn = get_git_status_setting()
if cmderGitStatusOptIn then
if git_dir then if git_dir then
-- if we're inside of git repo then try to detect current branch -- if we're inside of git repo then try to detect current branch
local branch = get_git_branch(git_dir) local branch = get_git_branch(git_dir)
local color local color = colors.unknown
if branch then if branch then
if cmderGitStatusOptIn ~= 'branchonly' then if cmderGitStatusOptIn then
-- Has branch => therefore it is a git folder, now figure out status -- Has branch => therefore it is a git folder, now figure out status
local gitStatus = get_git_status() local gitStatus = get_git_status()
local gitConflict = get_git_conflict() local gitConflict = get_git_conflict()
@ -423,14 +421,11 @@ local function git_prompt_filter()
if gitConflict then if gitConflict then
color = colors.conflict color = colors.conflict
end end
else end
color = colors.unknown
end
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")")
return false return false
end end
end
end end
-- No git present or not in git file -- No git present or not in git file