fix unknown color and code dedup

This commit is contained in:
dgames 2021-05-31 10:53:18 -04:00
parent 55ff611095
commit 56b04fc9ce
2 changed files with 22 additions and 30 deletions

50
vendor/clink.lua vendored
View File

@ -403,37 +403,29 @@ local function git_prompt_filter()
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)
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
else
if git_dir then
local branch = get_git_branch(git_dir)
if branch then
color = colors.nostatus
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

View File

@ -43,4 +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;1" -- White = No VCS Status Branch Color
unknown_color = "\x1b[37;1m" -- White = No VCS Status Branch Color