summaryrefslogtreecommitdiff
path: root/config/essentials/vis/title.lua
blob: 06a3964cb583b28eb5535b47cedb064c2354deeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--[[
Based on https://github.com/erf/vis-title
Changes made:
- stylua
--]]

require("vis")

local function set_title(title)
	-- print() cannot be used here as it will mess up vis
	vis:command(string.format(":!printf '\\033]2;vis %s\\007'", title))
end

vis.events.subscribe(vis.events.INIT, function()
	print("\27[22;2t")
end)

vis.events.subscribe(vis.events.WIN_OPEN, function(win)
	set_title(win.file.name or "[No Name]")
end)

vis.events.subscribe(vis.events.FILE_SAVE_POST, function(file)
	set_title(file.name)
end)

vis.events.subscribe(vis.events.QUIT, function()
	print("\27[23;2t")
end)