From 749ce17dbe873161d4ccc264ef80feda99f1af4e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 16 Sep 2018 15:53:49 -0500 Subject: [PATCH] git prompt yellow --- vendor/clink.lua | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/vendor/clink.lua b/vendor/clink.lua index 0b2c6be..3e7c6d7 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -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