Make terminal use pageup/pagedown instead of shift-pageup/shift-pagedown?

Solution 1:

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 good ol' 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: http://www.dsj.net/compedge/shellbasics1.html)

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 just hitting the q key.

Solution 2:

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...

Solution 3:

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

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

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

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

  6. 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.