mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-11 00:39:08 +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
|
return true
|
||||||
end
|
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
|
-- Get the status of working dir
|
||||||
-- @return {bool}
|
-- @return {bool}
|
||||||
@ -257,7 +272,8 @@ local function git_prompt_filter()
|
|||||||
-- Colors for git status
|
-- Colors for git status
|
||||||
local colors = {
|
local colors = {
|
||||||
clean = "\x1b[1;37;40m",
|
clean = "\x1b[1;37;40m",
|
||||||
dirty = "\x1b[31;1m",
|
dirty = "\x1b[33;3m",
|
||||||
|
conflict = "\x1b[31;1m"
|
||||||
}
|
}
|
||||||
|
|
||||||
local git_dir = get_git_dir()
|
local git_dir = get_git_dir()
|
||||||
@ -267,12 +283,18 @@ local function git_prompt_filter()
|
|||||||
local color
|
local color
|
||||||
if branch then
|
if branch then
|
||||||
-- Has branch => therefore it is a git folder, now figure out status
|
-- 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
|
color = colors.clean
|
||||||
else
|
|
||||||
color = colors.dirty
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if gitConflict then
|
||||||
|
color = colors.conflict
|
||||||
|
end
|
||||||
|
|
||||||
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..branch..")")
|
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..branch..")")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user