Lions used to discover odd UNIX programs by examining the output of ps on multiuser systems with actual multiple users. When they got their own personal UNIX boxes, those days ended. Screen was a very useful program lions once discovered, but forgot about. Not sure if it was originally just used on vt100's & xterm ended up replacing it or if the resolution was too low to have more than 1 xterm.
It was forgotten for 20 years, but would be useful in today's world of having to run browsers in multiple accounts. The lion kingdom's typical development environment has evolved into 5 xterms for 5 tasks which would best be consolidated:
openocd
telnet into openocd
builds
search commands
text editors
The basic screen commands:
ctrl-a c creates a new shell
ctrl-a n go to the next shell
ctrl-a p go to the previous shell
ctrl-a " shows the window list.
In the window list, , . move the highlighted window up or down the list.
ctrl-a ctrl-a toggles between 2 shells
More advanced commands:
ctrl-a d detach the current shell, making it a daemon. You can log out without ending it.
screen -r reattaches to the daemon & shows the terminal output
screen -ls shows the daemons
Scrolling in screen:
Screen by default doesn't use the xterm scroll buffer, but has its own buffer which is intended for copying text.
ctrl-a ESC enters the copy mode
In copy mode, ? / n cause it to search for text the same as less & vi, but it doesn't show line numbers or wrap around. g G cause it to go to the start & end.
cursor keys & pgup scroll back
ESC 3 times escapes from the copy mode
To erase the scroll buffer, you have to enter 2 commands with crtl-a :
scrollback 0
scrollback 1000
To make screen more intuitive, it must be forced to use the xterm scroll buffer by editing /etc/screenrc
This magic line should already be in /etc/screenrc & just need to be uncommented:
termcapinfo xterm|xterms|xs|rxvt ti@:te@
The xterm scroll buffer is not swapped when changing shells. You still have to go back to abusing the copy feature for that. Lions used to jump around the screen program like a pro & screen's disabling of the xterm scroll buffer makes lions believe it was originally just needed on vt100's.
The screenrc file also allows binding custom commands to keys, like erasing the scroll buffer.
There is a split screen mode, which defeats the purpose of multiplexing shells into a single terminal but looks neat.
The titles of the screens have to be customized. In Linux, it's done by appending a kludge to print an escape sequence right before the command prompt. It can't show the currently running program but it can show the prompt. It takes some doing to delete all the other PS1 declarations & make sure this is the only one:
export PS1='`whoami`@`hostname`:`pwd`% '
# customize the screen title
case $TERM in
screen*)
# ESC k ESC \ tells screen to set its title
# \w prints the working directory
SCREENTITLE='\[\ek`whoami`@`hostname`:\w\e\\\]'
;;
*)
SCREENTITLE=''
;;
esac
PS1="${SCREENTITLE}${PS1}"
Since its revival in 2019, the screen program has been a game changer. Lions spent over 20 years running the script program, loading typescript files, redirecting stderr to files & loading the files to view lengthy console output. It was a real pane to debug programs with long console output.
Having an adjustable scroll buffer with search functionality replaced all that with much simpler commands. It might have been a stretch to have a large scroll buffer when screen was introduced in 1987, but now the scroll buffer can easily replace a debug file.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
You'll find that a screen program still exists but is mainly used for maintaining a persistent session. Nowadays with large screens widely available there is no barrier to opening up lots of xterms.
Are you sure? yes | no