I am using a VTE based terminal. By manually sending the following command in a bash session, I see the scrollback buffer moving up by one line, so I am pretty confident the escape sequence is right:

printf "\e[2T"

I then added it to my .inputrc but it does not work. I tried various combination of keys and escape sequences without success: whenever I press CTRLk it just exits from vi insertion mode and nothing more.

Here is my full .inputrc

set editing-mode vi

# Line cursor in editing mode, block cursor in command mode
set vi-ins-mode-string \1\e[5 q\2
set vi-cmd-mode-string \1\e[2 q\2
set show-mode-in-prompt on

set keymap vi-insert
Control-l: clear-screen
Control-k: "\e[2T"
Control-j: "\e[S"

set keymap vi-command
Control-k: "\e[2T"
Control-j: "\e[S"
  • Have you realized that what this escape sequence does is very different from dragging the scrollbar? The bottom (normally visible) part scrolls down, empty lines are inserted at the top (between the normally visible and the scrollback part), lines at the bottom are dropped permanently, and the scrollbar does not move. – egmont May 21 at 9:08
  • 1
    The scrollback buffer cannot be navigated programatically (via escape sequences). The scrolling keys (Shift+PageUp/Down, Ctrl+Shift+Up/Down) are hardcoded, cannot be modified. – egmont May 21 at 9:08
  • @egmont This is really bad news. Do you know where those keybindings are hardcoded? I still have hard time understanding who is handling the scrollback buffer... The shell? The terminal? Readline? The kernel, libc, ...? – ntd May 22 at 12:46
  • 1
    The terminal, at gitlab.gnome.org/GNOME/vte/-/blob/0.60.2/src/vte.cc#L4797 . – egmont May 22 at 20:11

As highlighted by @egmont in the comments, the keybindings for scrolling the scrollback buffer are hardcoded in libvte.

There are some vte-based terminals, e.g. terminator or tilix, that allow to customize the keybindings for managing the scrollback buffer. I don't know how this is implemented but, after testing by myself, I can confirm this is exactly what I was looking for.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.