Skip to content

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

Open

Description

@chiefjester

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

Activity

  1. added
    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.
    on Sep 26, 2020
  2. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Sep 26, 2020
  3. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Sep 26, 2020
  4. skyline75489 commented on Sep 28, 2020

    @skyline75489
    Collaborator

    This sounds like a sibling of #642

  5. chiefjester commented on Sep 28, 2020

    @chiefjester
    Author

    Chester Liu (@skyline75489) Oh for #642 definitely! However with one big upside on this. If we go on this route, then we can skip the saving part and not build a UI out for it. Because we can already leverage that to the external pager/editor to do saving for us. Something that most terminal users know generally.

    This is a pretty powerful paradigm, to be honest. If you spend most of your time working on terminals, leveraging a TUI for your selection, marking, saving is going to feel second nature. It basically gives you superpowers. 🥳

  6. zadjii-msft commented on Sep 29, 2020

    @zadjii-msft
    Member

    I'm going to leave this open as an extension idea. It's definitely weird, and I'd hope that maybe someday the Terminals itself has all the features that you're looking for, so you don't need to rely on a 3rd party pager just to interact with the history in the Terminal 😝

  7. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Sep 29, 2020
  8. skyline75489 commented on Sep 29, 2020

    @skyline75489
    Collaborator
  9. chiefjester commented on Sep 30, 2020

    @chiefjester
    Author

    Hi Chester Liu (@skyline75489) 👋

    Do you happen to know other terminals that have this feature?

    Do you mean besides kitty? (I mentioned it in the first post) So far from what I used, alacritty uses a similar feature, which is it's vi-mode. It seems to be supporting basic vi movements -> h,j,k,l page up, page down, half-page up, have page down, word movement, end movement, etc. and yank.

    1. How Kitty is doing it:
    2. And here's alacritty's implementation:

    I've listed a proposed implementation:

    1. Default binding: ctrl-shift-h
    2. Pipes the whole buffer to stdin to a default program like less, or vi

    But now that I think of it, we don't even need to handle exiting the pager/program, because we're just passing the buffer via stdin and opening it normally. So just these two. ✌️

    Mike Griese (@zadjii-msft)
    I hope you don't dismiss the idea just because you feel weird. Maybe you don't get how this makes Microsoft Terminal very flexible. But I hope I can do justice. Here goes.

    Terminal users are mostly keyboard-driven individuals. The selection #2840 and mark mode #5804 is currently being built, was opened more than a year ago. I hope I don't hit a nerve, but I believe the one of the reason is still being "built" up to know is you have to build controls - scrolling, marking, selection, etc, which are all "basic" functions of a pager/editor, plus it has search too! 👌

    The whole idea of this proposal is to leverage existing pager/editor. So you get that scrolling, marking, selection, saving, searching out of the box, and for free 💰. This is extending what's already there. 🥳

    This is similar to supporting tmux's command mode, I can't see the issue, but I believe this is planned support too? But rather than supporting one external program like tmux, this is opening the possibility use a pager/editor that supports passing text via stdin, which is basically all pagers/editors? (maybe) or a big chunk of them 😃

    So as it currently stands, there's no way to do scrolling, yanking, saving the buffer to a text file, marking text via keyboard shortcuts. I think this proposal makes it a step closer because this drastically simplifies these features by leveraging existing external programs. Something that most terminal users are accustomed to and second nature to them.

    Things we can defer or skip if the proposal gets built:

    1. Introduce Mark Mode spec (add-on) #5804 - mark mode
    2. Keyboard Selection Spec #2840 - selection
    3. Feature request: export console history as txt #642 - saving history

    And on top of that we get all the powerful features an editor has, regex, macros, searching, etc. All given to us for free. I don't know what more bang of the buck feature proposal out there that takes this many features in one go. So again, I like to iterate, this proposal simplifies things, not complicate them. ✌️

  10. changed the title [-]ability to pipe scrollback buffer to a pager or temrinal editor[/-] [+]ability to pipe scrollback buffer to a pager or terminal editor[/+] on Sep 30, 2020
  11. changed the title [-]ability to pipe scrollback buffer to a pager or terminal editor[/-] [+]ability to pipe scrollback buffer to a pager or terminal editor like kitty[/+] on Sep 30, 2020
  12. DHowett commented on Sep 30, 2020

    @DHowett
    Member

    I think this is a super cool idea. It doesn't preclude the need for #5804, #2840 and #642, however; I rather consider it a nice extension to buffer management. Windows doesn't ship with a good pager by default (MORE.COM is not a good or useful pager), so we'd be saddling users with a default key combination that opens a hardcopy in notepad or even wordpad.

    I totally see the value. I just also think it's additive, not a replacement. 😄

  13. removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Oct 1, 2020
  14. chiefjester commented on Oct 1, 2020

    @chiefjester
    Author

    Dustin L. Howett (@DHowett) , I don't mean to alienate none WSL Window users, but now that Microsoft is pushing hard for WSL with a full team, it safe to say, most of the terminal users would be using WSL? However, for Dos users, there a winget vim?

    Given those rebuttal any chance you consider moving this out of Icebox? 👀

  15. SymphonySimper commented on Nov 25, 2025

    @SymphonySimper

    It is possible to do with "multipleActions".

    Note

    hx -> Helix Editor. Other editors should work as well.

    PowerShell

    {
     "actions": [
       {
         "id": "User.ScrollbackEditor",
         "command": {
           "action": "multipleActions",
           "actions": [
             { "action": "selectAll" },
             { "action": "copy" },
             { "action": "scrollToBottom" },
             {
               "action": "wt",
               "commandline": "--window 0 pwsh -c \"Get-Clipboard | hx\""
             }
           ]
         }
       }
     ],
     "keybindings": [{ "id": "User.ScrollbackEditor", "keys": "alt+v" }]
    }

    WSL

    Note

    I have used win32yank.exe for accessing clipboard. So make sure it's in your WSL distro's path.
    And replace NixOS with your WSL profile. If it has space in the name make sure to escape it with quotes.

    {
      "actions": [
        {
          "id": "User.ScrollbackEditorWSL",
          "command": {
            "action": "multipleActions",
            "actions": [
              { "action": "selectAll" },
              { "action": "copy" },
              { "action": "scrollToBottom" },
              {
                "action": "wt",
                "commandline": "--window 0 --profile NixOS bash -l -c \"win32yank.exe -o | hx\""
              }
            ]
          }
        }
      ],
      "keybindings": [{ "id": "User.ScrollbackEditorWSL", "keys": "alt+v" }]
    }
  16. DanSM-5 commented on May 5, 2026

    @DanSM-5

    It is possible to do with "multipleActions".

    Interesting, I've been looking for this for quite some time as I sometimes need to collect the output of some scripts to further processing.

    I found there is an action exportBuffer which allows to save the content of the buffer (scrollback) without depending on the clipboard.

            {
                "id": "User.ScrollbackEditor",
                "command": {
                    "action": "multipleActions",
                    "actions": [
                        { "action": "exportBuffer", "path": "%TEMP%/wt_scrollback.txt" },
                        { "action": "wt", "commandline": "nvim %TEMP%/wt_scrollback.txt" },
                    ]
                }
            }

    I'm saving the buffer to a temporary file %TEMP%/wt_scrollback.txt, then opening it with neovim. That also avoid the binaries dependency for the clipboard or the need of a separate command per profile (although it will always rely on the windows binary "nvim" in my case).

    Something that stills bothered me is that when closing the editor which opens in a new tab, it doesn't go back to focus the previous tab you were working on.

    To alleviate that I made a slightly change to the second action.

    { "action": "wt", "commandline": "--window last split-pane -c nvim %TEMP%/wt_scrollback.txt" },

    Now it opens in a split pane which is always in your current tab and on close you just get back to where you were.

    Hope this helps.

  17. SymphonySimper commented on May 5, 2026

    @SymphonySimper

    I found there is an action exportBuffer which allows to save the content of the buffer (scrollback) without depending on the clipboard.

    Great find! This makes the action much simpler. Here is what I ended up with.

    {
      "id": "User.ScrollbackEditor",
      "command": {
        "action": "multipleActions",
        "actions": [
          { "action": "exportBuffer", "path": "%TEMP%/wt_scrollback.txt" },
          {
            "action": "newTab",
            "tabTitle": "Scrollback Editor",
            "commandline": "hx %TEMP%/wt_scrollback.txt"
          }
        ]
      }
    }
  18. jclsn commented on Jun 16, 2026

    @jclsn

    Eduardo D Sanchez (@DanSM-5) Nice, that works much better. Would be nice to also have color support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-ExtensibilityA feature that would ideally be fulfilled by us having an extension model.Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.Product-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions