aboutsummaryrefslogtreecommitdiff
path: root/wscreen
blob: 2d9c0165111af88f2fe8227391494e2390e06d07 (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
31
32
33
34
35
36
37
38
39
40
41
#
# Workscreen: screen session wrapper
#
# Alternatives:
# http://byobu.co
# https://packages.debian.org/stable/byobu
# https://packages.debian.org/stable/screenie
# https://skoneka.github.io/screen-session
#

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

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

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

  if [ "$1" == "root" ]; then
    sudo screen -x
    exit
  elif [ -f "$HOME/.screen/$1" ]; then
    opts="-c $HOME/.screen/$1"
  elif [ -f "$HOME/.screen/base" ]; then
    opts="-c $HOME/.screen/base"
  else
    opts=""
  fi
fi

# Start session.
screen $opts $session