32 lines
811 B
Lua
32 lines
811 B
Lua
-- Initially from https://github.com/micro-editor/micro/issues/3991#issuecomment-3839167057
|
|
|
|
local buffer = import("micro/buffer")
|
|
|
|
function change_terminal_title(new_title)
|
|
local esc = string.char(0x1b)
|
|
io.write(esc, "]0;", new_title, esc, "\\")
|
|
end
|
|
|
|
function update_title(active_buf)
|
|
if active_buf.Type.Kind == buffer.BTRaw then
|
|
change_terminal_title("micro: Raw event viewer")
|
|
else
|
|
title = active_buf:GetName()
|
|
if title == "filemanager" then
|
|
-- Ignore this one
|
|
return
|
|
end
|
|
local new_title = string.format("micro: %s", title)
|
|
change_terminal_title(new_title)
|
|
end
|
|
end
|
|
|
|
function onBufferOpen(buf)
|
|
update_title(buf)
|
|
end
|
|
|
|
function onSetActive(bufpane)
|
|
if bufpane then
|
|
update_title(bufpane.Buf)
|
|
end
|
|
end
|