git prompt yellow

This commit is contained in:
Dax T. Games 2018-09-16 15:53:49 -05:00
parent 8cf59d1cbf
commit 749ce17dbe

30
vendor/clink.lua vendored
View File

@ -222,6 +222,21 @@ local function get_git_status()
return true
end
---
-- Gets the conflict status
-- @return {bool} indicating true for conflict, false for no conflicts
---
function get_git_conflict()
local file = io.popen("git diff --name-only --diff-filter=U 2>nul")
for line in file:lines() do
file:close()
return true;
end
file:close()
return false
end
---
-- Get the status of working dir
-- @return {bool}
@ -257,7 +272,8 @@ local function git_prompt_filter()
-- Colors for git status
local colors = {
clean = "\x1b[1;37;40m",
dirty = "\x1b[31;1m",
dirty = "\x1b[33;3m",
conflict = "\x1b[31;1m"
}
local git_dir = get_git_dir()
@ -267,12 +283,18 @@ local function git_prompt_filter()
local color
if branch then
-- Has branch => therefore it is a git folder, now figure out status
if get_git_status() then
local gitStatus = get_git_status()
local gitConflict = get_git_conflict()
color = colors.dirty
if gitStatus then
color = colors.clean
else
color = colors.dirty
end
if gitConflict then
color = colors.conflict
end
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..branch..")")
return false
end