I am writing automation scripts (perl
/bash
). Many of them benefit from some basic terminal GUI. I figured I'd use standard ANSI
sequences for basic drawing. Before drawing in terminal I do clear
but doing that I lose some terminal command history. I want to be able to restore terminal command history when my program exists. Many terminal programs (e.g. less
, man
, vim
, htop
, nmon
, whiptail
, dialog
etc) do exactly that. All of them restore terminal window bringing the user back to where he was prior to calling the program with all the history of commands previously executed.
To be honest I don't even know where to start searching. Is it a command from curses
library? Is it an ANSI
escape sequence? Should I mess with tty
? I am stuck and any pointers would be really helpful.
EDIT: I'd like to clarify that I am not really asking "how to use the alternative screen". I am looking for a way to preserve terminal command history. One possible answer to my question could be "use alternative screen". The question "what is alternative screen and how to use it" is a different question which in turn already has answers posted elsewhere. Thanks :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…