<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>${me:-whatever} &#187; screen</title>
	<atom:link href="http://samrowe.com/wordpress/tag/screen/feed/" rel="self" type="application/rss+xml" />
	<link>http://samrowe.com/wordpress</link>
	<description></description>
	<lastBuildDate>Tue, 01 May 2012 14:02:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>GNU Screen quick tips</title>
		<link>http://samrowe.com/wordpress/2010/06/16/gnu-screen-quick-tips/</link>
		<comments>http://samrowe.com/wordpress/2010/06/16/gnu-screen-quick-tips/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 15:49:36 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://samrowe.com/wordpress/?p=231</guid>
		<description><![CDATA[I use GNU Screen [henceforth: "screen"] every single day in a variety of contexts. I&#8217;m by no means an expert, but I&#8217;ve met a few people who aren&#8217;t as familiar with some of screen&#8217;s more oblique features, so I&#8217;ll give you a walk-through of my setup. If you&#8217;re new to screen, this isn&#8217;t likely the [...]]]></description>
			<content:encoded><![CDATA[<p>I use GNU Screen [henceforth: "screen"] every single day in a variety of contexts. I&#8217;m by no means an expert, but I&#8217;ve met a few people who aren&#8217;t as familiar with some of screen&#8217;s more oblique features, so I&#8217;ll give you a walk-through of my setup. If you&#8217;re new to screen, this isn&#8217;t likely the best place to start. Also, this isn&#8217;t a replacement for the man page. I barely know anything, so read the friendly manual and learn even more.</p>
<p>If you already know screen, I&#8217;m going to discuss setting up an &#8220;outer&#8221; screen with an alternate command key as well as using screen&#8217;s copy mode to capture text. If you already know how to do that you&#8217;ll find nothing new here.</p>
<p>First we&#8217;ll start with a very small script I wrote called <a href="http://github.com/riddley/bashfiles/blob/master/bin/outer">outer</a>. I run this script on my desktop and it creates a screen whose command key is F12. I do this so that when I connect to remote machines (where the command key is still the default of ^a) I&#8217;m able to think less because I don&#8217;t have to escape remote command keys.</p>
<p>Here&#8217;s a scenario that might shed some light on my explanation. Without overriding the command key, you start screen on your desktop and ssh to a remote host where you start screen. Now if you want to interact with the remote screen session, you have to &#8220;escape&#8221; your commands to it so that the desktop&#8217;s screen doesn&#8217;t interpret them. If you type ^a-c your desktop screen is going to create a new window. If you want that new window on the remote host, you have to type ^a-a-c, which can get annoying quickly. With outer, your desktop&#8217;s command key is F12, so it doesn&#8217;t care at all about your remote ^a&#8217;s.</p>
<p>For some gravy, outer also sets up F11 as &#8220;windowlist -m&#8221; which is a list of your windows in use-order. Since I&#8217;ve met a few people who don&#8217;t know about windowlist, if you hit command-key-&#8221; is a list of your windows in numerical order (windowlist -b). Further gravy, outer also always grabs the current version of your .screenrc before it starts screen.</p>
<p>My <a href="http://github.com/riddley/bashfiles">shell environment</a> automatically names my screen windows to the hostname when instantiating a shell, so my &#8220;windowlist -m&#8221; might look like this:</p>
<pre class="syntax bash">
Num Name                         Flags

  0 mutt                             $
  1 puppet                           $
 10 henry                            $
 15 machinex                         $
  8 machiney                         $
  2 jables                           $
 13 machinez                         $
  3 kage                             $
  6 storooni                         $
  4 lee                              $
  7 dude                             $
  9 walter                           $
  5 donnie                           $
 11 maude                            $
</pre>
<p>You can navigate the windowlist with j/k/arrowkeys and enter.</p>
<p>Screen&#8217;s copy mode can be used for capturing its scrollback contents to a file. To enter copy mode, hit command-key-Esc. If you&#8217;re familiar with vi/vim, you&#8217;re now in something akin to vi/vim&#8217;s command mode. Movement keys in this mode are very similar to vi/vim, but not exactly; so read the man page. Once you&#8217;re in copy mode, move your cursor to a given point in the scrollback buffer and then hit the space bar. By hitting the spacebar, you&#8217;ve dropped a marker at the cursor location. Move again to select text. Once you&#8217;ve selected the text you want, hit &gt;. Hitting &gt; will save the selection to a file whose name is the value of &#8220;bufferfile&#8221;. The default is /tmp/screen-exchange. Yea I know: horrible name. I guess that&#8217;s why it&#8217;s configurable.</p>
<p>You can also use copy mode to paste into your screen session. The details of that I&#8217;ll leave as an exercise to the reader.</p>
<p>I frequently connect to hardware consoles via telnet/ssh, where selecting text from a terminal emulator with a mouse often adds unwanted spaces or new lines. Copy mode is invaluable for preserving the formatting of the consoles&#8217; text.</p>
]]></content:encoded>
			<wfw:commentRss>http://samrowe.com/wordpress/2010/06/16/gnu-screen-quick-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash &amp; Screen</title>
		<link>http://samrowe.com/wordpress/2008/07/15/bash_and_screen/</link>
		<comments>http://samrowe.com/wordpress/2008/07/15/bash_and_screen/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 01:59:00 +0000</pubDate>
		<dc:creator>sam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://samrowe.com/wordpress/?p=1</guid>
		<description><![CDATA[You may be familiar with my tutorial on getting your ssh-agent to work inside screen. If not, have a look. There&#8217;s always room for improvements! Here&#8217;s an excerpt from my current .bash_profile: function Attach(){ grabssh if [[ -z "${1}" ]] ; then local n=`screen -wipe &#124; egrep -i 'attached&#124;detached' &#124; wc -l` if [[ "${n}" [...]]]></description>
			<content:encoded><![CDATA[<p>You may be familiar with my <a title="deadman.org tutorial" href="http://deadman.org/sshscreen.html">tutorial</a> on getting your ssh-agent to work inside screen. If not, have a look.</p>
<p>There&#8217;s always room for improvements! Here&#8217;s an excerpt from my current .bash_profile:</p>
<pre>
function Attach(){
    grabssh
    if [[ -z "${1}" ]] ; then
        local n=`screen -wipe | egrep -i 'attached|detached' | wc -l`
        if [[ "${n}" -gt 1 ]]; then
            check_screen
            return
        fi
    fi
    echo screen -d -R ${*}
    screen -d -R ${*}
}

check_screen () {
  # Look in the path?
    type screen > /dev/null 2>&#038;1
    if [[ ${?} = 0 ]]; then
        tmp=0
        echo
        for scr in `screen -wipe | egrep -i 'attached|detached' | awk '{print $1"_"$2}'`
        do
            echo "Screen available: ${scr}"
            if [[ ${tmp} -eq 0 ]] ; then
                myscreen=${scr%_*}
            fi
            tmp=$(($tmp+1))
        done
        if [[ -n "${myscreen}" ]] ; then
            echo
            echo "Enter to attach to ${myscreen},"
            echo "'n' to move on,"
            echo "unique bits to attach elsewhere"
            read eon
            if [[ -z "${eon}" ]] ; then
                [[ -z "${myscreen}" ]] &#038;&#038; return
                eon=${myscreen}
            fi
            if [[ "${eon}" != 'n' ]] ; then
                Attach ${eon}
            fi
        fi
    fi
}

[[ -n "$PS1" ]] &#038;&#038; check_screen
</pre>
<p>If screen(s) exist, I&#8217;m presented with a list of them on login. I&#8217;m then able to hit return for a default, or type in which of them I wish to resume.</p>
<p>If I don&#8217;t want to resume any screen I can simply hit &#8216;n&#8217; and go on about my day.</p>
<p>The Attach and check_screen functions are actually in a different file that is sourced by .bashrc and conditionally by .bash_login. This allows the functions to be used in non-login shells (in local terminal windows for example).</p>
]]></content:encoded>
			<wfw:commentRss>http://samrowe.com/wordpress/2008/07/15/bash_and_screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

