Why can't I scroll in the terminal?

To reinitialize the terminal, a simple reset will fix this. For more info and options, man reset


@James Henstridge's answer to this AskUbuntu question seems to identify the error correctly as the terminal getting stuck in a "cursor addressing" mode, whatever that means.

His first solution, the command $ tput rmcup, works, though there's not much in the way of explanation. So, I attempted to figure that out.

man tput tells us that

The tput utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell (see sh(1)), to initialize or reset the terminal, or return the long name of the requested terminal type.

terminfo is also not very usefully documented. The most comprehensive source I can find is a tldp.org article. Evidently terminfo is a database of different terminals and what commands and capabilities they have. Presumably every Linux installation has one? So you can use different terminals?

man terminfo indicates its files are in /etc/terminfo/*/*, but on Ubuntu 16.04 I found only a README there. The real files are in /lib/terminfo/*/*; e.g. /lib/terminfo/l/linux, which is probably the most relevant file for most readers? I can't tell, because these files are not human-readable. The tldp.org article linked above states that infocmp can be used to see their source, but that isn't true:

$ infocmp /lib/terminfo/l/linux
infocmp: couldn't open terminfo file /lib/terminfo/l/linux.

The article also mentions source code files /etc/termcap and /etc/terminfo.src, but these do not exist in Ubuntu 16.04. I did find a set of /usr/share/vte/termcap*/ directories that contain human-readable xterm files. I'd have to guess that this all connects to the GNOME Terminal I'm using that's default to Ubuntu, but I'm tired of trying to figure out how.

The man page for terminfo does have one more helpful jot, though. Under its 'Predefined Capabilities' is a 'Variable String' exit_ca_mode with 'capname' ("capability name", I assume) rmcup with the description strings to end programs using cup. The description isn't very helpful, but the variable name is; this must refer to a terminal's capability to exit 'cursor addressing mode', which is what the terminal is stuck in.

So, $ tput rmcup must use tput to access the terminfo database and activate the current terminal's exit_ca_mode capability rmcup, which kills the cursor addressing mode and returns the terminal to its normal scrolling behavior.

Tags:

Linux

Terminal