-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper.sh
More file actions
executable file
·40 lines (33 loc) · 768 Bytes
/
wrapper.sh
File metadata and controls
executable file
·40 lines (33 loc) · 768 Bytes
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
#!/bin/bash
# set flag vars to empty
COMMAND= SESSION=
while getopts :c:s: opt
do
case $opt in
c) COMMAND=$OPTARG
;;
s) SESSION=$OPTARG
;;
'?') echo "$0: invalid option -$OPTARG" >&2
echo "Usage: $0 -c command -s tmux-session" >&2
exit 1
;;
esac
done
if [ ! -n "${COMMAND}" ]; then
echo "Usage: $0 -c command -s tmux-session" >&2
exit 1
fi
if [ ! -n "${SESSION}" ]; then
echo "Usage: $0 -c command -s tmux-session" >&2
exit 1
fi
# If session doesn't exist, create it
if /usr/bin/tmux has -t "${SESSION}" 2>/dev/null
then
:
else
/usr/bin/tmux new-session -d -s "${SESSION}"
fi
# Run SCRIPT in the tmux SESSION
/usr/bin/tmux send-keys -t "${SESSION}":0 "${COMMAND}" ENTER