-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtx
More file actions
executable file
·36 lines (30 loc) · 735 Bytes
/
tx
File metadata and controls
executable file
·36 lines (30 loc) · 735 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
#!/bin/bash
layouts_dir="$HOME/.tmux/layouts"
if [ $# -eq 0 ]; then
echo "usage: $0 <layout>"
echo "available session layouts:"
ls -1 "$layouts_dir"
exit 1
fi
export SESSION_NAME="$1"
export ROOT_DIR="$2"
# Check if the session already exists
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
echo "Session $SESSION_NAME already exists. Attaching to it..."
sleep 1
else
# Perform custom layout
layout="$layouts_dir/$SESSION_NAME"
if [ -f "$layout" ]; then
source "$layout"
else
echo "error: unknown layout: $layout"
exit 1
fi
unset layout
fi
# Attach to the session
tmux switch -t "$SESSION_NAME"
unset SESSION_NAME
unset ROOT_DIR
unset layouts_dir