aboutsummaryrefslogtreecommitdiff
path: root/wscreen
blob: dac001b296ffc5bac16480cfda98fd791bb03878 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
# Workscreen: screen session wrapper
#

# Default options.
opts="-c /etc/screenrc"

# Remove dead screens.
screen -wipe &> /dev/null

# Session selection.
if [ ! -z "$1" ]; then
  if screen -ls $1 | grep -q "There is a screen on"; then
    #echo "There's already a screen called $1"
    #exit 1
    screen -x $1
    exit $?
  else
    session="-S $1"
  fi

  if [ "$1" == "main" ]; then
    opts=""
  elif [ -f "$HOME/.screen/$1" ]; then
    opts="-c $HOME/.screen/$1"
  fi
fi

# Start session.
screen $opts $session