@@ -35,7 +35,9 @@ sidebar_pane_args() {
35
35
}
36
36
37
37
register_sidebar () {
38
- set_tmux_option " ${REGISTERED_SIDEBAR_PREFIX} -${1} " " sidebar"
38
+ local sidebar_id=" $1 "
39
+ local pane_id=" $2 "
40
+ set_tmux_option " ${REGISTERED_SIDEBAR_PREFIX} -${sidebar_id} " " $pane_id "
39
41
}
40
42
41
43
register_sidebar_for_current_pane () {
@@ -131,7 +133,7 @@ create_sidebar() {
131
133
local sidebar_info=$( tmux split-window " $( orientation_option) " -c " $PANE_CURRENT_PATH " -P -F " #{pane_id},#{pane_width}" " $COMMAND " )
132
134
local sidebar_id=$( echo " $sidebar_info " | cut -d' ,' -f1)
133
135
local sidebar_width=$( echo " $sidebar_info " | cut -d' ,' -f2) # half a pane
134
- register_sidebar " $sidebar_id "
136
+ register_sidebar " $sidebar_id " " $PANE_ID "
135
137
register_sidebar_for_current_pane " $sidebar_id "
136
138
if sidebar_left; then
137
139
tmux swap-pane -U
@@ -158,11 +160,11 @@ current_pane_too_narrow() {
158
160
[ $PANE_WIDTH -lt 81 ]
159
161
}
160
162
161
- exit_unless_pane_can_have_sidebar () {
162
- if current_pane_is_sidebar ; then
163
- display_message " Sidebars can't have sidebars! "
164
- exit
165
- fi
163
+ execute_command_from_main_pane () {
164
+ # get pane_id for this sidebar
165
+ local main_pane_id= " $( get_tmux_option " ${REGISTERED_SIDEBAR_PREFIX} - ${PANE_ID} " " " ) "
166
+ # execute the same command as if from the "main" pane
167
+ $CURRENT_DIR /toggle.sh " $ARGS " " $main_pane_id "
166
168
}
167
169
168
170
exit_if_pane_too_narrow () {
@@ -187,8 +189,11 @@ toggle_sidebar() {
187
189
188
190
main () {
189
191
if supported_tmux_version_ok; then
190
- exit_unless_pane_can_have_sidebar
191
- toggle_sidebar
192
+ if current_pane_is_sidebar; then
193
+ execute_command_from_main_pane
194
+ else
195
+ toggle_sidebar
196
+ fi
192
197
fi
193
198
}
194
199
main
0 commit comments