mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
git prompt yellow
This commit is contained in:
parent
8cf59d1cbf
commit
749ce17dbe
30
vendor/clink.lua
vendored
30
vendor/clink.lua
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user