Created
January 7, 2016 18:33
-
-
Save vladimir-kotikov/ef164c3baa8b80bd30b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git_prompt_filter_new() | |
local start_filter = os.clock() | |
-- Colors for git status | |
local colors = { | |
clean = "\x1b[1;37;40m", | |
dirty = "\x1b[31;1m", | |
} | |
local git_info = {} | |
local proc = io.popen("git rev-parse --git-dir --short --abbrev-ref HEAD 2>nul") | |
if proc then | |
for line in proc:lines() do | |
table.insert(git_info, line) | |
end | |
proc:close() | |
end | |
if #git_info == 0 then | |
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", "") | |
print(string.format("elapsed time: %.2f", os.clock() - start_filter)) | |
return false | |
end | |
local branch = git_info[2] | |
local color = get_git_status() and colors.clean or colors.dirty | |
clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..branch..")") | |
print(string.format("elapsed time: %.2f", os.clock() - start_filter)) | |
return false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment