-
Notifications
You must be signed in to change notification settings - Fork 0
/
decorate-internal
43 lines (38 loc) · 914 Bytes
/
decorate-internal
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
42
43
# global var for storing the last created window
_last_window=
# send a command to the active pane
_features_send() {
target="$1"; shift
cmd="$1"; shift
tmux send-keys -t "$target" "$cmd" Enter
}
# create a pane split via the given switch and send a command
_features_create_pane() {
type="$1"; shift
cmd="$1"
pane="$(tmux list-panes -t "$_last_window" -F '#{pane_id}' | tail -n1)"
created="$(tmux split-window -dP -t "$pane" "$type")"
if [ "$cmd" ]; then
_features_send "$created" "$cmd"
fi
}
# create a named window and run a command
w() {
name="$1"; shift
cmd="$1"
window="$(tmux new-window -n "$name" -dP)"
_last_window="$window"
if [ "$cmd" ]; then
_features_send "$window" "$cmd"
fi
}
# split horizontally and send command
h() {
cmd="$1"
_features_create_pane -h "$cmd"
}
# split vertically and send command
v() {
cmd="$1"
_features_create_pane -v "$cmd"
}