File tree Expand file tree Collapse file tree 4 files changed +17
-11
lines changed Expand file tree Collapse file tree 4 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,11 @@ switch_to_session() {
52
52
local session_name=" $1 "
53
53
tmux switch-client -t " $session_name "
54
54
}
55
+
56
+ create_session () {
57
+ if [ " $( get_tmux_option " @sessionist-maintain-path" ) " == " on" ]; then
58
+ TMUX=" " tmux -S " $( tmux_socket) " new-session -c " $1 " -d -P -F " #{session_id}"
59
+ else
60
+ TMUX=" " tmux -S " $( tmux_socket) " new-session -d -P -F " #{session_id}"
61
+ fi
62
+ }
Original file line number Diff line number Diff line change @@ -20,11 +20,9 @@ create_new_tmux_session() {
20
20
else
21
21
# New session name may differ from the input. Eg input name may be
22
22
# 'foo.bar', but new name will be 'foo_bar'.
23
- #
24
- # -c "#{pane_current_path}" has to be specified, otherwise a random path is
25
- # used for the new session.
26
- local session_name=$( TMUX=" " tmux -S " $( tmux_socket) " new-session -d -P -c " #{pane_current_path}" -s " $SESSION_NAME " )
27
- switch_to_session " $session_name "
23
+ local pane_current_path=$( tmux display-message -p " #{pane_current_path}" )
24
+ local session_id=$( create_session " $pane_current_path " )
25
+ switch_to_session " $session_id "
28
26
fi
29
27
}
30
28
Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ new_session_pane_id() {
25
25
}
26
26
27
27
promote_pane () {
28
- local session_name =" $( create_new_session ) "
29
- local new_session_pane_id=" $( new_session_pane_id " $session_name " ) "
28
+ local session_id =" $( create_session " $PANE_CURRENT_PATH " ) "
29
+ local new_session_pane_id=" $( new_session_pane_id " $session_id " ) "
30
30
tmux join-pane -s " $CURRENT_PANE_ID " -t " $new_session_pane_id "
31
31
tmux kill-pane -t " $new_session_pane_id "
32
- switch_to_session " $session_name "
32
+ switch_to_session " $session_id "
33
33
}
34
34
35
35
main () {
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ new_session_window_id() {
26
26
}
27
27
28
28
promote_window () {
29
- local session_name =" $( create_new_session ) "
30
- local new_session_window_id=" $( new_session_window_id " $session_name " ) "
29
+ local session_id =" $( create_session " $WINDOW_CURRENT_PATH " ) "
30
+ local new_session_window_id=" $( new_session_window_id " $session_id " ) "
31
31
tmux swap-window -s " $CURRENT_WINDOW_ID " -t " $new_session_window_id "
32
32
tmux kill-window -t " $new_session_window_id "
33
- switch_to_session " $session_name "
33
+ switch_to_session " $session_id "
34
34
}
35
35
36
36
main () {
You can’t perform that action at this time.
0 commit comments