On Mac, the reset command in terminal almost does the same thing as clear. On Ubuntu Linux, and maybe other flavors of Linux, the reset command actually "resets" the terminal so that you can't scroll up or see previously input commands by scrolling. Is there a way to make the reset command on Mac act/do the same thing as reset does on Linux? If so, how can I do it?

  • Try tput reset – user2497 Dec 23 '17 at 10:35

Actually (on MacOS), it's not "the exact same thing" (the manual page description for "clear" is different from "reset").

MacOS comes with ncurses 5.7 (9 years old), with some updates to the terminal database. If you want something newer, installing MacPorts lets you update ncurses to the current (less a few months) version.

By the way, that would be newer than Ubuntu, which generally lags development versions by 6 months to 2 or more years.

  • So ncurses does what reset on Linux does? – StrangeRanger Dec 22 '17 at 23:51
  • sure - they're both ncurses. You can see the version using "infocmp -V" – Thomas Dickey Dec 23 '17 at 0:00

This is a bit of an historical artefact. In the dawn of Unix time_t, computers were the big boxes in the datacenter, and terminals were separate pieces of hardware that were used to communicate with them. A terminal did not necessarily come from the same manufacturer as the computer, and each terminal manufacturer and model had their own set of extra features and quirks that had to be taken into account.

curses, and its later successor ncurses are libraries that hide all the make-and-model-dependent specifics of the terminals and provide standard ways to do terminal control operations like "clearing the screen" or "resetting the terminal to sane default settings". These libraries use the environment variable TERM to decide which set of control sequences should be used.

Commands like clear and reset use such libraries to translate the operation requested by the user into terminal-model-specific control sequences and send them to the terminal. These model-specific control sequences are stored into termcap or terminfo files - termcap is the old style, and terminfo is what is used by ncurses.

Today, it is very common that the "terminal" is actually a terminal emulator that runs on the same physical hardware as the actual computer. But it is still controlled as if it was a separate piece of hardware.

This leaves the programmer of the terminal emulator a certain degree of freedom to choose how specific features should be implemented. For example, the programmer might make it so that resetting the terminal will clear the scroll-back buffer - or s/he might choose otherwise, if s/he's of the opinion that the scrollback buffer "belongs" to the user and no application should have the power to clear it.

Alternatively, the programmer of the terminal emulator might have provided different control sequences for resetting the terminal either with or without clearing the scrollback buffer. In this case, the person packaging the terminal control libraries for an OS distribution will have a choice to make: should the reset command clear the scrollback by default or not? Depending on the choice, s/he can store a different control sequence in the appropriate location in the data files used by the terminal control libraries.

It has always been possible for the system administrator to add new sets of terminal control sequences to the termcap or terminfo files, or to modify existing ones. Perhaps some site had a terminal model that was not widely known, or perhaps a standard definition required just a bit of tweaking to match a particular use case. If it turns out that the default control sequence used by the reset command actually is "reset terminal without clearing scrollback", you could replace it with a "reset terminal and scrollback" code in the files.

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.