]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
zsh: Fix attachment to running screen sessions.
authorSimon Ruderich <simon@ruderich.org>
Fri, 8 May 2009 12:42:26 +0000 (14:42 +0200)
committerSimon Ruderich <simon@ruderich.org>
Fri, 8 May 2009 12:42:26 +0000 (14:42 +0200)
zsh/rc

diff --git a/zsh/rc b/zsh/rc
index b82f75f2447c851f77157db6bb58babda43202f1..e17deede06e225861738d4706f65b0f9b7ae7589 100644 (file)
--- a/zsh/rc
+++ b/zsh/rc
@@ -418,12 +418,14 @@ alias vqs='vim -c "cd $(hg root)/.hg/patches/" "$(hg root)/.hg/patches/series"'
 # screen* is necessary as `screen` uses screen.linux for example for a linux
 # console which would otherwise cause an infinite loop.
 if [[ $TERM != screen* && $TERM != 'dumb' ]]; then
+    # Get running detached sessions.
+    session=$(screen -list | grep 'Detached' | awk '{ print $1; exit }')
     # Create a new session if none is running.
-    if [[ $(screen -list | grep "Detached" | wc -l) == 0 ]]; then
+    if [[ -z $session ]]; then
         screen
     # Reattach to a running session.
     else
-        screen -r
+        screen -r $session
     fi
 fi