Skip to content

Instantly share code, notes, and snippets.

@ItzaMi
Created April 14, 2026 12:00
Show Gist options
  • Select an option

  • Save ItzaMi/d8da1e779d05ce40a66ed75ddeae2433 to your computer and use it in GitHub Desktop.

Select an option

Save ItzaMi/d8da1e779d05ce40a66ed75ddeae2433 to your computer and use it in GitHub Desktop.
runtime / live-edit for tmux panes - on exiting session, ask for one more pane and it sorts out a reasonable spot for it
#!/bin/bash
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
panes=$(tmux list-panes | wc -l | tr -d ' ')
if [ "$panes" -eq 1 ]; then
tmux split-window -h -l 33% -c "#{pane_current_path}"
else
target=$(tmux list-panes -F '#{pane_id} #{pane_left} #{pane_top}' \
| sort -k2,2nr -k3,3nr | head -1 | awk '{print $1}')
tmux split-window -v -t "$target" -c "#{pane_current_path}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment