Close

remembering the screen program

A project log for Silly software wishlist

Motivation to do some software projects by writing them down.

lion mclionheadlion mclionhead 09/08/2019 at 19:461 Comment

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 all the shells

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 odd buffer which requires using its copy feature to scroll into.

ctrl-a ESC enters copy mode

cursor keys scroll back

ESC again escapes from the copy mode

The alternative is forcing screen 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.

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}"

Discussions

Ken Yap wrote 09/08/2019 at 22:40 point

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