<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Alex's Adventures on the Infobahn - screen</title><link href="https://www.bennee.com/~alex/" rel="alternate"></link><link href="https://www.bennee.com/~alex/blog/tag/screen/feed" rel="self"></link><id>https://www.bennee.com/~alex/</id><updated>2010-11-03T15:33:00+00:00</updated><subtitle>the wanderings of a supposed digital native</subtitle><entry><title>A step towards reducing Emacs Pinky</title><link href="https://www.bennee.com/~alex/blog/2010/11/03/a-step-towards-reducing-emacs-pinky/" rel="alternate"></link><published>2010-11-03T15:33:00+00:00</published><updated>2010-11-03T15:33:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2010-11-03:/~alex/blog/2010/11/03/a-step-towards-reducing-emacs-pinky/</id><summary type="html">&lt;p&gt;As someone who spends most of the day attached to their keyboard I'm fairly sensitive to RSI inducing things. One thing I do suffer from is what's colloquially known as &amp;quot;Emacs Pinky&amp;quot;. As the Ctrl is the start of practically every editing command in Emacs it's the left little finger …&lt;/p&gt;</summary><content type="html">&lt;p&gt;As someone who spends most of the day attached to their keyboard I'm fairly sensitive to RSI inducing things. One thing I do suffer from is what's colloquially known as &amp;quot;Emacs Pinky&amp;quot;. As the Ctrl is the start of practically every editing command in Emacs it's the left little finger that spends most of it's time stretched out and after a long heavy coding session can be more than a little sore.&lt;/p&gt;
&lt;p&gt;I've made adaptations including re-binding the useless Caps Lock key to being an alternative to Ctrl (although my use of it is sporadic). However one other culprit is the incredibly useful &lt;a class="reference external" href="http://en.wikipedia.org/wiki/GNU_Screen"&gt;GNU Screen&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I've been running with the default bindings for some time which use the Ctrl-A sequence as the command sequence. This is especially troubling when you have multiple nested screens. Today I finally cracked and made the decision to &lt;a class="reference external" href="https://github.com/stsquad/dotfiles/commit/61a201d930f9919143a607b11d9840481cf7e172"&gt;break out of this bad habit&lt;/a&gt;. So starting today I've chosen the backtick (`) character for the escape sequence. This makes the normal (and most frequent) screen action of switching screens a two stroke press without having to hold any control key down. We shall see how long it takes to retrain my muscle memory.&lt;/p&gt;
&lt;p&gt;Does anyone have any tips for reducing strain on the little finger inside Emacs itself? Sometimes I wonder if it would be easier to replace Ctrl actions with a double tap on the space bar before going for the modifier key. Is that even possible?&lt;/p&gt;
&lt;p&gt;I found &lt;a class="reference external" href="http://superuser.com/questions/74492/whats-the-best-prefix-escape-sequence-for-screen-or-tmux"&gt;this entry on superuser&lt;/a&gt; useful for other screen config tips.&lt;/p&gt;
</content><category term="geek"></category><category term="emacs"></category><category term="screen"></category></entry><entry><title>Restoring GUI connectivity from screen</title><link href="https://www.bennee.com/~alex/blog/2009/11/19/restoring-gui-connectivity-from-screen/" rel="alternate"></link><published>2009-11-19T14:48:00+00:00</published><updated>2009-11-19T14:48:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2009-11-19:/~alex/blog/2009/11/19/restoring-gui-connectivity-from-screen/</id><summary type="html">&lt;p&gt;&lt;a class="reference external" href="http://en.wikipedia.org/wiki/GNU_Screen"&gt;GNU Screen&lt;/a&gt; is one of the most useful tools in my arsenal. In the days before I used screen I used to make extensive use of Gnome Terminal's multiple tab functionality. I'd have one tab for edit/commit commands, one for running code, others for watching logs and the plethora …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a class="reference external" href="http://en.wikipedia.org/wiki/GNU_Screen"&gt;GNU Screen&lt;/a&gt; is one of the most useful tools in my arsenal. In the days before I used screen I used to make extensive use of Gnome Terminal's multiple tab functionality. I'd have one tab for edit/commit commands, one for running code, others for watching logs and the plethora of other tasks you may be doing while working on something. Whenever X went down (sadly a fairly common occurrence if you are a heavy &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Compiz"&gt;Compiz&lt;/a&gt; user) I spent a significant amount of time recreating my terminal sessions.&lt;/p&gt;
&lt;p&gt;With screen all that happens is the controlling terminal detaches, preserving all the running processes inside and allowing a simple reattach once you have a GUI again. As a bonus you can do this at any time, this is most useful when working from home. All I need to do is logon to my machine remotely and attach to the screen session and I can pick up from where I left of the previous day. It's also incredibly useful for servers. I read all my mail in &lt;a class="reference external" href="http://www.mutt.org/"&gt;Mutt&lt;/a&gt; running in a screen session on my server which I can attach to from anywhere on the net.&lt;/p&gt;
&lt;p&gt;One problem however is GUI environments, specifically talking to various agents and the like. As the &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Shell_%28computing%29"&gt;shell&lt;/a&gt; inside the screen never terminates the environment variables telling it how to talk to things like the &lt;a class="reference external" href="http://en.wikipedia.org/wiki/X_session_manager"&gt;Session Manager&lt;/a&gt; or the various other desktop agents will not be updated. So I spent a little time hacking up a solution to the problem. First of all I need to detect when in the GUI and dump the environment variables somewhere:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
ENV_DUMP_FILE=&amp;quot;${HOME}/current_${HOSTNAME}.env&amp;quot;
alias dump_env=&amp;quot;env &amp;gt; ${ENV_DUMP_FILE}&amp;quot;

# If in a GUI dump the current environment
# This is not perfect, if you spawn an xterm out of your screen session it
# vape your carefully stored environment, so don't do that.
if [[ ${TERM} == &amp;quot;screen&amp;quot; ]]; then
    echo &amp;quot;In a screen session - run restore_gui_env to pick up GUI vars&amp;quot;
elif [[ ${TERM} == &amp;quot;linux&amp;quot; ]]; then
    echo &amp;quot;In a console session&amp;quot;
else
    echo &amp;quot;In a GUI session - dumping env in ${ENV_DUMP_FILE}&amp;quot;
    dump_env
fi
&lt;/pre&gt;
&lt;p&gt;Once that is done I have a simple function I can run to slurp up the relevant environment variables into my current screen session:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# Restore a single environment variable from ${ENV_DUMP_FILE}
function restore_env_var
{
    if [[ &amp;quot;$1&amp;quot;  &amp;amp;&amp;amp; -f ${ENV_DUMP_FILE} ]]
    then
        line=`grep $1 ${ENV_DUMP_FILE}`
        delim=`expr index $line =`
        value=${line:$delim}
        echo &amp;quot;export $1=$value&amp;quot;
        export $1=$value
    fi
}

function restore_gui_env
{
    echo &amp;quot;Restoring GUI environment settings&amp;quot;
    restore_env_var DBUS_SESSION_BUS_ADDRESS
    restore_env_var XDG_SESSION_COOKIE
    restore_env_var DISPLAY
    restore_env_var SSH_AUTH_SOCK
    restore_env_var GPG_AGENT_INFO
    restore_env_var GNOME_KEYRING_SOCKET
}
&lt;/pre&gt;
&lt;p&gt;It's not perfect, for example if I spawn a GUI shell from inside screen it could overwrite the current correct environment with stale data. However I think that's just a case of &amp;quot;don't do that then&amp;quot;. The changes can be seen in context in my &lt;a class="reference external" href="http://github.com/stsquad/dotfiles/commit/d80ed1426ab5f49d527ddac56c690d03e0a34078"&gt;dotfiles repo&lt;/a&gt;.&lt;/p&gt;
</content><category term="geek"></category><category term="bash"></category><category term="bashrc"></category><category term="screen"></category><category term="session"></category><category term="terminal"></category></entry></feed>