16

I've grown quite weary of shift-pgup to page up in gnome terminal, the command line, terminator, and guake, etc.

Any way to easily make these apps use the straight page-up and page-down keys for paging around?

1
  • It works in the vscode terminal. Just change via the shorcuts UI. It works for the shell and for an application in the shell (for example less). No need to press shift.
    – guettli
    Jan 26 at 12:23

4 Answers 4

10

I am afraid this is not possible, as no PgUp/PgDown will be sent to command-line applications, which will render some of them unusable. This is a good old days Unix feature.

If you want more user-friendly scrolling, I suggest using the less command. It's used this way:

command-with-lot-of-output | less

This will start the less command with output of your original command. (*More about piping output to other programs can be found here.

less can be navigated using arrows or PgUp/PgDown. For your convenience it also provides searching and more (see man less for more). You can quit less by pressing the q key.

4
  • 3
    I researched the heck out of this and while it seems there at 100+ keystrokes that you can map in the command console, page-up and page-down aren't two of them!
    – Dave
    Sep 13, 2012 at 22:36
  • 1
    less is not suitable for just scrolling up/down in the contents of your terminal, and invoking it is hardly more convenient than pressing shift. Not Jakub's fault at all, but it's sad there isn't an answer to this question. Jan 30, 2014 at 12:13
  • @HDave here is how to do it in xterm unix.stackexchange.com/questions/339160/…
    – William
    Jan 23, 2017 at 1:57
  • 1
    @JonathanHartley here is how to do it in xterm unix.stackexchange.com/questions/339160/…
    – William
    Jan 23, 2017 at 1:57
2

Konsole is a terminal emulator for KDE that provides relevant option, in which can be configured to use Page Up and Page Down keys for direct paging. There are no other terminal emulators that I found as easy as Konsole for such customization.

How to direct paging

In Konsole, do the following steps.

  1. In menu bar, go to "Settings" and click "Configure Current Profile..." (Kubuntu 12.04) or "Edit Current Profile..." (Kubuntu 16.04) and a window will appear.

  2. Click on "Input" tab (Kubuntu 12.04) or "Keyboard" tab (Kubuntu 16.04), which has a section called "Key Bindings" with predefined lists of key bindings.

Key Bindings in Konsole

  1. Select "Default (XFree 4)" and click "Edit..." button, then another window will appear.

  2. Scroll down and look for key combination PgDown-Shift-AnyModifier with output \E[6~. Rename this output to ScrollPageDown.

  3. Scroll down and look for key combination PgUp-Shift-AnyModifier with output \E[5~. Rename this output to ScrollPageUp.

  4. Click "OK" button to finish and close the windows.

How to test output

In step 3, there is "Test Area" to confirm the output for each key press.

  • Click to bring focus in "Input:" text field and press Page Up and Page Down keys (one at a time).

  • Confirm the output to be the same as renamed ones.

    Key Bindings List and Test Area in Konsole

Or, write a simple script to echo message in loop. I have included my own script as following.

  • Copy and paste the following lines of code in text editor.

          #!/bin/bash
    
          echo "Started script"
          echo "If no input, then loop"
          while true
          do {
              echo "Hello, world"
              echo "Wait 1 second to loop [q to quit]"
              read -t 1 -n 1 INPUT && echo
              if [ "$INPUT" == "q" ]
                  then break
                  else echo "UTC now: $(date -u +%H%M%S)"
              fi
              continue
          }
          done
          echo "Ended script"
    
  • Save as file i.e. loop.sh and run the script in terminal i.e. bash loop.sh (non-executable).

  • Wait until the echoed messages fill the viewing area and started to scroll output downwards.

  • Then, press Page Up and Page Down keys to scroll up and scroll down the viewing area.

I have tested using Konsole 2.8.5, KDE 4.8.5 in Kubuntu 12.04.

Bonus: Key combination and output

Alright, bonus answer for clarification. One may wonder why I had to edit those key combination and not others. I had figured that out earlier by testing several types of keyboard.

The following are default key combination and its output, which have been figured out using "Test Area" in Konsole.

For primary Page Up/Page Down keys (including keyboard variant that requires to press Fn key a.k.a. Fn+PgUp/Fn+PgDn):

  • Key combination: PgDown-Shift-AnyModifier Output: \E[6~

  • Key combination: PgUp-Shift-AnyModifier Output: \E[5~

For secondary Page Up/Page Down keys (default shortcut in terminal that requires Shift key a.k.a. Shift+PgUp/Shift+PgDn):

  • Key combination: PgDown+Shift-AppScreen Output: ScrollPageDown

  • Key combination: PgUp+Shift-AppScreen Output: ScrollPageUp

Notice that minus - and plus + signs differ between each keywords for primary and secondary keys. Those are how key presses are translated into equivalent characters, at least in Konsole.

However, I'm unsure if those equivalent characters are actually understood by other terminal emulators. This is as far as I know by own experience.

Verdict

For power users who don't like dealing with various configuration files and such tedious workarounds, Konsole will easily win your heart. It seems that nobody had noticed to this level of customization offered by Konsole and KDE for the past four years. How strange.

7
  • So I'm trying to get ride of pressing the shift setting the key combination to PgDown doesn't seem to work for some reason.
    – William
    Jan 24, 2017 at 20:53
  • You mean to remove default shortcut? If emptying the output field doesn't work, replace default output ScrollPageDown, ScrollPageUp with formerly replaced \E[6~, \E[5~ for PgDown+Shift-AppScreen and PgUp+Shift-AppScreen key combo respectively. It is important to click "OK" for settings to apply.
    – user37165
    Jan 25, 2017 at 3:14
  • no I would like to not have to press Shift at the same time of PgDown and PgUp. I do not believe this answered the question.
    – William
    Jan 25, 2017 at 3:15
  • You mean step 4, 5 didn't work for you? Strange. Any screenshot with link to show what you are seeing?
    – user37165
    Jan 25, 2017 at 3:18
  • 1
    This worked like a charm in Konsole 16.08.3 on Fedora 24. There are a few minor differences- the tab is called "Keyboard" instead of "Input", but the bottom line is that part showing how to rename the output was spot on. Thanks for removing a 10 year itch I've had! ++1 ... If I could give +10, I would.
    – Mike S
    Feb 13, 2017 at 0:16
1
+50

Use xterm and tweak the keybindings (in ~/.Xresources) like this:

xterm*VT100.Translations: #override \n\
    <KeyPress>Prior:scroll-back(1,page)\n\
    <KeyPress>Next:scroll-forw(1,page)\n\

gnome-terminal says PageUp/PageDown is for applications within the terminal and using them would be confusing...

2
  • then why does xterm support the option and not gnome terminal? Either way I am the one that both linked the answer above and posted the bounty I'm not giving a bounty to this answer.
    – William
    Jan 23, 2017 at 23:14
  • askubuntu.com/users/33577/liam-william Oops, I didn't read until the bottom (at the top, it's about the clipboard). And: fair enough! I wouldn't give it to me: I tried to post an URL that supports my gnome-terminal statemtent, but all I found were outdated, i.e. non-existant links...
    – aba
    Jan 24, 2017 at 13:09
-2

You can use the more command like this:

command-with-lots-of-output  |  more

this will start your command original output with more.

more can be navigated with 'space'. Just press the space and see the output of the command as pages.

1
  • You can only page-down with more. No page-ups for you, sir.
    – DrBeco
    Jul 25, 2022 at 22:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .