aboutsummaryrefslogtreecommitdiff
path: root/tools/screen_run
diff options
context:
space:
mode:
Diffstat (limited to 'tools/screen_run')
-rwxr-xr-xtools/screen_run21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/screen_run b/tools/screen_run
new file mode 100755
index 0000000..97baff4
--- /dev/null
+++ b/tools/screen_run
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# Connect to a named screen session if it exists, otherwise create it
+# If creating a new screen session, use the file screenrc.$session
+# in the .tools directory.
+#
+screen_dir=$HOME/.screen
+session=$1
+function die() {
+ echo "$0 error: $*"
+ exit 1
+}
+[ $# -ne 1 ] && die "$0 requires 1 argument (screen session name)"
+if screen -ls | grep $session; then
+ # This session exists, connect to it
+ screen -r $session
+else
+ session_config=$screen_dir/screenrc.$session
+ [ -f $session_config ] || die "config ($session_config) not found for $session"
+ screen -c $screen_dir/screenrc.$session -S $session
+fi