Terminals

From Jeremy Bryan Smith
Revision as of 17:30, 10 July 2025 by Jeremy (talk | contribs)
Jump to navigation Jump to search

Linux Virtual Console

Enabling Key Bindings

One annoyance I have with the default configuration of the virtual console is that it doesn't enable the Ctrl+Left and Ctrl+Right key bindings to move to the previous/next word. Here is how you can do that:

  • Determine the escape sequences that are being generated when you press Ctrl+Left and Ctrl+Right. Within a virtual terminal, run the cat command and then: press Ctrl+Left, a few spaces, then Ctrl+Right. The escape sequences will be output. Make a note of those. Then press Ctrl+C to exit. For example:
jeremy@thinkpadx1gen6 ~ $ cat
^[[D      ^[[C
  • In your ~/.inputrc file, add the following (replacing the escape sequences below with your own if they are different):

# Allow ctrl+left and ctrl+right keys to move to previous/next word in virtual terminal
# The \e here represents the beginning escape sequence: ^[

# Ctrl + Left
"\e[D": backward-word

# Ctrl + Right
"\e[C": forward-word

Note that the key sequences being sent by those key combinations are different within an X11 session. In my case the X11 bindings are already set up by default, but here they are for reference:


# Allow ctrl+left and ctrl+right keys to move to previous/next word in X11

"\e[1;5D": backward-word

"\e[1;5C": forward-word

The changes will take effect the next time you open a terminal. If you want the changes to take effect immediately, run this:

bind -f ~/.inputrc


Framebuffer Scrollback Buffer

To increase the size of the framebuffer scrollback buffer, use the fbcon kernel parameter:

fbcon=scrollback:Nk

Where N is a number. The default: N=32k

Serial Terminals

Dealing with a serial TTY smaller than your terminal

  • Open tmux
  • Press Ctrl+B q to see the tmux pane size (e.g. 190x41)
  • Open the serial connection (e.g. with minicom or screen)
  • Set TTY rows and cols:
    stty rows 41 cols 190
  • Profit