aboutsummaryrefslogtreecommitdiff
path: root/tmuxrdr/plugin/bin/break-pane
blob: f2683c93d80285422167fc1774b993b3588af0b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
# tmux prefix+! (break-pane): the current pane becomes a tab of its own, at the
# end of the tab bar, and that tab is selected. Same message as tmux when the
# pane is alone.
. "$(dirname "$0")/../lib.sh"

p="$(active_pane)"
[ "$(tab_panes "$p" | wc -l)" -gt 1 ] || fail "can't break with only one pane"
tab="$("$H" pane move "$p" --new-tab --workspace "$(pane_info "$p" workspace_id)" \
    --no-focus | jq -r '.result.move_result.pane.tab_id // empty')"
[ -n "$tab" ] || fail "break-pane failed"
# Focused separately: a move's own --focus emits no tab.focused event, so
# track-focus would miss it and `last window` would not lead back.
"$H" tab focus "$tab" >/dev/null