{"id":42,"date":"2009-10-15T22:07:30","date_gmt":"2009-10-15T22:07:30","guid":{"rendered":"https:\/\/chroot-me.in\/newblog\/2009\/10\/42\/"},"modified":"2014-01-30T02:36:53","modified_gmt":"2014-01-30T01:36:53","slug":"howto-using-a-gnu-screen-inside-another-gnu-screen","status":"publish","type":"post","link":"https:\/\/chroot-me.in\/blog\/2009\/10\/howto-using-a-gnu-screen-inside-another-gnu-screen\/","title":{"rendered":"HOWTO: Using a GNU screen inside another GNU screen"},"content":{"rendered":"<p>I found this feature this morning, and the irc folks being enthusiastic, I decided to <em>blag<\/em> about it.<\/p>\n<p>I use GNU screen on a daily basis for almost three years. Not only able to provide an almost complete terminal emulation, with detach and reattach abilities, extensive keyboard bindings, tabs (a.k.a windows) management, Gnu screen is a versatile tool, although surprisingly more than often ignored by a lot of people.<\/p>\n<p><a href=\"http:\/\/www.gnu.org\/software\/screen\/\">There<\/a> is a little reminder of what GNU screen consists in.<\/p>\n<h3>Requirements, or at least highly recommended setup<\/h3>\n<p>It is highly recommended to have a <strong>screenrc<\/strong> that provides a <em>hardstatus<\/em> line, the only practical way to distinguish one screen from another.<\/p>\n<p>Here is mine:<\/p>\n<div class=\"cmd\">\n<pre>shell \/bin\/zsh\r\nattrcolor b \".I\"\r\ntermcapinfo xterm 'Co#256:AB=\\E[48;5;%dm:AF=\\E[38;5;%dm' \r\ndefbce \"on\"\r\nterm screen-256color\r\nmaptimeout 5\r\ntermcapinfo xterm* ti@:te@\r\nhardstatus alwayslastline\r\nhardstatus string '%{= kG}[%{G}%H%{g} %l][%=%{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u\r\n)%?%{r})%{w}%?%+Lw%?%?%=%{g}][%{B}%d\/%m %{W}%c%{g}]'\r\ndefnonblock 5<\/pre>\n<\/div>\n<p>Of course, you should adapt this to fit your needs, only the lines beginning with hardstatus are relevant there.<\/p>\n<p>Now that your GNU screen is properly configured, I can highlight the bullet point of this howto :)<\/p>\n<h3>Pictures are said to help comprehension. I say LIES!<\/h3>\n<p>My X terminal emulator is <a href=\"http:\/\/www.tenshu.net\/terminator\/\">Terminator<\/a>. Combined with GNU screen, you can obtain &#8230; that&#8230;thing:<\/p>\n<p><a href=\"https:\/\/chroot-me.in\/blog\/media\/images\/gnu_screen\/fullsize.png\"><img decoding=\"async\" alt=\"'what. the. heck?'\" src=\"https:\/\/chroot-me.in\/blog\/media\/images\/gnu_screen\/thumb.png\" \/><\/a><\/p>\n<p>(click on the thumbnail to maximize)<\/p>\n<p>Please bear with me, even if this caused some eye-melting :P<\/p>\n<p>Some explanations: each zone delimited by light grey borders are in fact splits in Terminator. Gnu screen sessions are contained in the numbered splits.<\/p>\n<p>1: err&#8230; not really a screen, I guess I&rsquo;m tired and too lazy to correct the picture.<\/p>\n<p>2: lwatch on dresda<\/p>\n<p>3: lwatch on pandora<\/p>\n<p>4: htop on dresda<\/p>\n<p>5: htop on pandora<\/p>\n<p>6: irssi on dresda<\/p>\n<p>The only thing I had to do is to execute <strong><tt>screen -e ^ee<\/tt><\/strong> on <strong>pandora<\/strong>, therefore rebinding all default <strong><tt>^a<\/tt><\/strong> (Ctrl+a) bindings to <strong><tt>^e <\/tt><\/strong>(Ctrl+e).<\/p>\n<p>Then you control the main screen with the default binding, while controlling the inner screen with these new binds (i.e ^ac to create a new window in the main screen, ^ec to do the same in the inner screen :)<\/p>\n<p>Finally, the relevant part in <tt>man screen<\/tt>:<\/p>\n<div class=\"cmd\">\n<pre>       -e xy\r\n            specifies the command character to be x and the character generat\u2010\r\n            ing a literal command character to y (when typed after the command\r\n            character).  The default is \"C-a\" and `a', which can be  specified\r\n            as  \"-e^Aa\".  When creating a screen session, this option sets the\r\n            default command character. In a multiuser session all users  added\r\n            will  start off with this command character. But when attaching to\r\n            an already running session, this option changes only  the  command\r\n            character  of  the  attaching  user.  This option is equivalent to\r\n            either the commands \"defescape\" or \"escape\" respectively.<\/pre>\n<\/div>\n<p>I really enjoy it, it&rsquo;s like a Christmas present for all BOFHs, blinking like a Christmas Tree when some jerk is trying to mess with your servers\/networks :D<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found this feature this morning, and the irc folks being enthusiastic, I decided to blag about it. I use GNU screen on a daily basis for almost three years. Not only able to provide an almost complete terminal emulation, with detach and reattach abilities, extensive keyboard bindings, tabs (a.k.a windows) management, Gnu screen is &hellip; <a href=\"https:\/\/chroot-me.in\/blog\/2009\/10\/howto-using-a-gnu-screen-inside-another-gnu-screen\/\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;HOWTO: Using a GNU screen inside another GNU screen&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,4,2],"tags":[],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-english","category-geek","category-hacks"],"_links":{"self":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":0,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}