-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtmsetup
executable file
·74 lines (59 loc) · 2.55 KB
/
tmsetup
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /bin/bash
# tmsetup
# Author: Austin Burt
# Email: [email protected]
# github: github.com/arburty/tmsetup-commnand
# Date: 3/27/19
detach=false
[[ $1 == "-d" ]] && detach=true && shift
# either give the session a name as the only argument or workspace is used
declare -r NAME=${1:-"workspace"}
# if the session doesn't exist create it. otherwise attach to it
tmux has-session -t $NAME 2>/dev/null
if [[ $? != 0 ]]; then
# new session with NAME and a 'workstation' window split in 2 panes
tmux new -s ${NAME} -n workstation -d
tmux split-window -h -t $NAME
# new window named 'vim'
tmux new-window -n vim -t $NAME
# new window named 'extra'
tmux new-window -n extra -t $NAME
# open ranger in fourth window
# ranger is not a built in command. Not portable
tmux new-window -n ranger -t $NAME
tmux send-keys -t $NAME 'ranger' C-m
# open mutt in last window if the workspace
# mutt and friends are not a built in command. Not portable
if [[ $NAME == 'workspace' ]]; then
tmux new-window -n mutt -t $NAME
tmux send-keys -t $NAME 'neomutt' C-m
# not setting the size with -l for some reason. resize-pane also didn't work
tmux split-window -d -v -l 5 -t $NAME 'while true;do mbsync -a;done'
tmux resize-pane -Z -t $NAME
fi
# 2 window switches so 'vim' is the last-window
# if windows start at index 0 these need to be decremented by 1
tmux select-window -t ${NAME}:2
tmux select-window -t ${NAME}:1
# run git status and branch to see current working state with no output if
# not in a git directory the commented out line is the more portable
# equivalent
sleep 1
# tmux send-keys -t $NAME \
# 'clear && git status -s 2>/dev/null && git branch 2>/dev/null' C-m
# if the workspace session, change pane to dotfiles-and-scripts directory
[[ $NAME == 'workspace' ]] && tmux send-keys -t $NAME \
'clear && cd ~/git/dotfiles-and-scripts/' C-m
# a welcome screen I created to show weather, git stuff, and my todo's This
# part is not portable, the above should be used ('welcome' is in
# github.com/arburty/dotfiles-and-scripts/bin)
tmux send-keys -t $NAME 'welcome' C-m
# attmept to make welcom full screen
[[ $detach == "true" ]] || sleep 1.5
tmux send-keys -t $NAME 'M'
# move to left pane to start the session
tmux select-pane -L
fi
# Only create the session if detach is true, do not attach to it. Otherwise attach
[[ $detach == "true" ]] && echo "tmux session '$NAME' created" || tmux attach -t $NAME
exit 0