From: Simon Ruderich Date: Fri, 8 May 2009 12:42:26 +0000 (+0200) Subject: zsh: Fix attachment to running screen sessions. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=627b2da3d018476eec991653bc721174fe46f2d9;p=config%2Fdotfiles.git zsh: Fix attachment to running screen sessions. --- diff --git a/zsh/rc b/zsh/rc index b82f75f..e17deed 100644 --- 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