Files
dotfiles/erc
2017-07-18 23:24:28 -04:00

57 lines
1.0 KiB
Plaintext

set_tab(2)
function starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
meta_commands["blame"] = function()
_, y = get_coords()
handle = io.popen("git blame --porcelain -L"..tostring(math.floor(y)+1)..","..tostring(math.floor(y)+1).." "..get_filename())
lines = handle:read("*a")
handle:close()
author = string.match(lines, "author (%a+)")
message(author)
end
keys["%"] = function()
s = get_text()
count = 0
for word in s:gmatch("%w+") do count = count + 1 end
message(count .. " words")
end
keys["!"] = function()
command = prompt("shell command: %s")
command = string.gsub(command, "%$", get_filename())
handle = io.popen(command)
result = handle:read("*a")
handle:close()
result = string.gsub(result, "\n", " ")
message(result)
end
function get_meta_commands()
res = ""
for k, _ in pairs(meta_commands) do
res = res .. k .. ", "
end
return res
end
function get_keys()
res = ""
for k, _ in pairs(keys) do
res = res .. k .. ", "
end
return res
end