microsoft / microsoft/terminal

ability to pipe scrollback buffer to a pager or terminal editor like kitty

Open
#7,749 11 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Extensibility Issue-Feature Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

Ability to pipe scrollback buffer to a pager or terminal editor

This is basically what kitty does with ctrl-shift-h. By default it just uses less, but you can use any pager or terminal editor just as long as it understands ANSI escape codes. eg scrollback_pager nvim -c 'set ft=man' -.

I believe this is a more powerful way to mark, select, copy than introducing mark mode (#5804) and selection spec (#2840). Because it leverages all the features a terminal editor has as oppose to have arbitrary bindings that only exist in Microsoft Terminal.

Don't get me wrong, while I know I just said that this is more powerful, I'm not saying this could replace, but rather be a powerful complement to those PRs.

I guess the right approach is just dumping the whole buffer to stdin and piping it to whatever command we set in JSON configuration.

With Microsoft Terminal already supporting splits and tabs, this could totally replace tmux for me. And I do think this is a superior approach since terminal multiplexers tend to just duplicate all the escape sequences you type, which is wasteful. Having the Terminal handle your splits, and scrollback buffer is what most people use terminal multiplexer is for.

Some might say, "but what about sessions?". Tmux is an odd program since it is both a session manager and a terminal multiplexer. This solves the latter by completing the trifecta - splits, tabs, scrollback buffer.

This should complement the history size configuration. Since having a large amount of scrollback buffer could lead to slowdowns. But using vim for years, I never found a file that it couldn't handle, (I'm talking about opening gigabytes worth of log files).

Proposed technical implementation details (optional)
  1. Default binding: ctrl-shift-h
  2. Pipes the whole buffer to stdin to a default program like less
    2a. (optional) We could remove all the ANSI Escape codes by default, that way you just pipe it directly to your terminal like vim -M +MANPAGER -, I have to use sed to remove them when using it in kitty.
  3. Ability to change the scrollback pager program via scrollbackPager in JSON Config.
  4. closing the scrollback pager would bring you back to where you invoked to command

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; start by locating the scrollback-buffer implementation, keybinding handling, and JSON configuration paths. Compare the requested Ctrl+Shift+H behavior with existing pager or terminal-launch flows. Done means the full buffer can be sent to a configurable pager or editor, with ANSI handling and return-to-terminal behavior defined and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.