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 git_dir = get_git_dir()
local color local color
cmderGitStatusOptIn = get_git_status_setting() cmderGitStatusOptIn = get_git_status_setting()
if cmderGitStatusOptIn then if git_dir then
if git_dir then local branch = get_git_branch(git_dir)
-- if we're inside of git repo then try to detect current branch if branch then
local branch = get_git_branch(git_dir) if cmderGitStatusOptIn then
if branch 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 -- 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()
color = colors.dirty color = colors.dirty
if gitStatus then if gitStatus then
color = colors.clean color = colors.clean
end end
if gitConflict then if gitConflict then
color = colors.conflict color = colors.conflict
end end
else
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") color = colors.nostatus
return false end
end clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")")
end return false
else end
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
end end
-- No git present or not in git file -- 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" clean_color = "\x1b[1;37;40m"
dirty_color = "\x1b[33;3m" dirty_color = "\x1b[33;3m"
conflict_color = "\x1b[31;1m" 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