File tree 3 files changed +73
-1
lines changed
3 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ dotfiles_config() {
34
34
' config/dotfiles/shellrc/hooks/post-shellrc.sh'
35
35
' config/shellrc'
36
36
' config/vim/vimrc'
37
+ ' config/tmux.init'
37
38
' config/tmux.conf'
38
39
' config/ranger/rc.conf'
39
40
' config/ranger/rifle.conf'
Original file line number Diff line number Diff line change @@ -681,7 +681,8 @@ alias shellrc='"$EDITOR" "$DOTFILES_HOME/config/shellrc"'
681
681
alias sync=' sudo "$(which syncf)"'
682
682
alias t-display-restore=' tmux setenv -g DISPLAY :0'
683
683
alias t=' tmux'
684
- alias ta=' tmux-attach'
684
+ alias ta=' tmux-init || tmux-attach'
685
+ alias tmux-init=' bash "$(custom-env-resolve "config/tmux.init")"'
685
686
alias tf=' tail -F'
686
687
alias tmain=' tmux-attach main'
687
688
alias tp=' tp_get'
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -eu
4
+ set -xv
5
+
6
+ session_name=' ssh'
7
+
8
+ main () {
9
+ if [[ " ${1:- } " == ' setup_session' ]]; then
10
+ set_env
11
+ setup_session " $@ "
12
+ else
13
+ create_session " $@ "
14
+ fi
15
+ }
16
+
17
+ set_env () {
18
+ export DISPLAY=:0
19
+ tmux setenv DISPLAY " $DISPLAY "
20
+ }
21
+
22
+ create_session () {
23
+ if tmux has-session -t " $session_name " ; then
24
+ if [[ " $session_name " == ' ssh' ]]; then
25
+ echo " Session has already started." >&2
26
+ exit 1
27
+ else
28
+ tmux kill-session -t " $session_name "
29
+ fi
30
+ fi
31
+
32
+ tmux new-session -d -s " $session_name " " exec bash $( realpath " $0 " ) setup_session"
33
+
34
+ if [[ -z " ${TMUX:- } " ]]; then
35
+ tmux attach -t " $session_name "
36
+ else
37
+ tmux switch-client -t " $session_name "
38
+ fi
39
+ }
40
+
41
+ new_window () {
42
+ local dir=" $1 "
43
+ local name=" ${2:- } "
44
+
45
+ if [[ -z " $name " ]]; then
46
+ name=" $( basename " $dir " ) "
47
+ fi
48
+
49
+ tmux new-window -c " $dir " -n " $name "
50
+ }
51
+
52
+ send () {
53
+ tmux send-keys " $@ "
54
+ }
55
+
56
+ setup_session () {
57
+ new_window ~ scratch
58
+ send ' vim' Enter
59
+
60
+ new_window ~ /.dotfiles dotfiles
61
+ send ' gst' Enter
62
+ tmux split-window -c " #{pane_current_path}"
63
+ send ' cd custom' Enter
64
+ send ' gst' Enter
65
+ tmux select-pane -t 1
66
+
67
+ tmux select-window -t scratch
68
+ }
69
+
70
+ main " $@ "
You can’t perform that action at this time.
0 commit comments