OttyAddons
All addons

Scrollback in Editor

Built in

Open a pane's scrollback in your editor — search it, yank from it, save it — then quit to come back.

What it can do

  • actionsAdds commands you can run from the command palette or bind to a key.
  • pane.readReads the text of a pane, scrollback included.
  • fs.tempWrites files into a temporary folder of its own, and nowhere else.
  • pane.openOpens a new tab or split that runs a command.

Settings

Shown under the addon in Settings › Labs once it’s on.

SettingTypeDefaultDetails
Editor commandeditor Text nvim + {path} {path} is replaced with the file. Runs in your shell, so anything on your PATH works.
Open inplacement Choice tab One of tab, split-right, split-down.
Lines of scrollbackmax_lines Number 10000 From 100 to 200000.

Turn it on

  1. Turn on Feature Preview in Settings › Advanced, or add feature-preview = true to your config.toml.
  2. Open Settings › Labs and switch Addons on.
  3. Switch Scrollback in Editor on. Its settings show up right under it.

Source

The whole addon is this script and its addon.toml.

main.luau29 lines
-- Scrollback in Editor: the pane's scrollback as plain text in $EDITOR,
-- opened in a new tab or split that closes when the editor quits.

local function quote(path: string): string
	return "'" .. string.gsub(path, "'", "'\\''") .. "'"
end

otty.action({
	id = "open",
	title = "Open Scrollback in Editor",
	run = function(ctx)
		local text = otty.pane.text(ctx.pane_id, {
			scrollback = true,
			max_lines = otty.setting("max_lines"),
		})
		local name = "scrollback-" .. string.gsub(ctx.pane_id, "[^%w%-_]", "_") .. ".txt"
		local path = otty.fs.write_temp(name, text)
		local editor = string.gsub(otty.setting("editor"), "{path}", function()
			return quote(path)
		end)
		otty.pane.open({
			-- `exec` so the pane goes away with the editor.
			command = "exec " .. editor,
			cwd = ctx.cwd,
			placement = otty.setting("placement"),
			pane_id = ctx.pane_id,
		})
	end,
})