Launch a shell command in an ephemeral tmux pane
I often want to quickly run a command in a new tmux pane without losing my current shell context. I essentially want the Control + Click “Open in New Tab” from the browser in tmux. We can achieve this by creating a zsh line editor widget which reads the current buffer and runs a tmux command. Here is a minimal example bound to Ctrl-\: # Widget to run current command in new tmux pane tmux_split_with_current_command() { # Execute tmux split-window with the current command (tmux split-window -h "$BUFFER" &) } # Create the widget from the function zle -N tmux_split_with_current_command # Bind Ctrl-\ to the widget bindkey '^\' tmux_split_with_current_command It uses a subshell and runs the command in the background to minimize the affect on the current shell and return control to the current shell as soon as possible....