Inject a command into the active tmux session, automatically splitting into the biggest pane (or creating a new window once a pane limit is reached).
./tmux-inject.zsh "ls -la"If no command is given, it defaults to ls.
- Finds the currently active tmux session, window, and pane.
- If the current window already has
max_pane_per_windowpanes (default: 4), a new window is created and the command is sent there. - Otherwise, the largest pane is split (horizontally or vertically, depending on its aspect ratio) and the command is sent into the new pane.
Edit tmux-inject.zsh to change:
tmux— path to yourtmuxbinary (default:/usr/local/bin/tmux)max_pane_per_window— max panes per window before a new window is created (default:4)
You can use this script as a handler for opening connections (e.g. telnet) into a tmux pane. In your console application preferences, edit the launch command and paste:
osascript -e 'do shell script "/path/to/tmux-inject.zsh \"telnet %h %p\" "'- zsh
- tmux