-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdtach_run
executable file
·40 lines (34 loc) · 944 Bytes
/
dtach_run
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
#!/bin/sh
#--------
# Convenience script to use with the [[https://github.com/bogner/dtach][dtach tool]].
#
# It will run in a detached session whatever arguments are given,
# assigning automatically a pertinent socket.
#
# If it's called from a symlink starting with "d", it will use
# the name of the symlink as the command to call (for example,
# symlink "dbash" will start a detached bash session).
#
# Also, for non-US keyboard friendliness, it will use Control+Q
# as default escape shortcut to dettach the session (overriden by
# DTACH_ESCAPE)
#--------
name=$(basename "$0")
if [ "$name" = "dtach_run" ]
then
name=$1
else
bin=${name#d}
fi
if [ -z "$bin $@" ]
then
cat <<EOF
Usage: ${0##*/} command [ARGUMENTS]
List of currently dettached command sessions:
EOF
ll "${TMPDIR:-/tmp}/*.dtach_session"
fi
exec dtach -A "${TMPDIR:-/tmp}/$name.dtach_session" \
-e ${DTACH_ESCAPE:-^q} \
-r ${DTACH_REDRAW:-winch} \
$bin "$@"