diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gitstatus.lua | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua index b7ff5de..fda1388 100644 --- a/plugins/gitstatus.lua +++ b/plugins/gitstatus.lua @@ -13,13 +13,9 @@ local git = { local function exec(cmd, wait) - local tempfile = core.temp_filename() - system.exec(string.format("%s > %q", cmd, tempfile)) - coroutine.yield(wait) - local fp = io.open(tempfile) - local res = fp:read("*a") - fp:close() - os.remove(tempfile) + local proc = process.start(cmd) + proc:wait(wait * 1000) + local res = proc:read_stdout() return res end @@ -28,10 +24,10 @@ core.add_thread(function() while true do if system.get_file_info(".git") then -- get branch name - git.branch = exec("git rev-parse --abbrev-ref HEAD", 1):match("[^\n]*") + git.branch = exec({"git", "rev-parse", "--abbrev-ref", "HEAD"}, 1):match("[^\n]*") -- get diff - local line = exec("git diff --stat", 1):match("[^\n]*%s*$") + local line = exec({"git", "diff", "--stat"}, 1):match("[^\n]*%s*$") git.inserts = tonumber(line:match("(%d+) ins")) or 0 git.deletes = tonumber(line:match("(%d+) del")) or 0 |