I have a tmux window that I've opened with a certain command. Is it possible to split that window with a new pane which also runs the same command, not the default command?

The point is to avoid having to remember and type the original command again.


#{pane_start_command} is a way to access the command used to start the current pane. This is available since v1.7 (10/2012).

bind-key S run-shell "tmux split-window \"#{pane_start_command}\""
is a solution for your question using #{pane_start_command}. (tmux version >= 1.9 (02/2014)).

With versions 1.7 >= X < 1.9 you can use something like this in your ~/tmux.conf file:

bind-key S run-shell "tmux split-window \"$(tmux display-message -p '#{pane_start_command}')\""
  • The substituted display-message command extracts #{pane_start_command}.
  • That command is given as an argument to tmux split-window.

pane_start_command will be the empty string if the pane was started without a command string and there was no default-command, but that is okay because split-window will start a plain login shell if it is given an empty command string.


The command your are looking for is split-window. From man tmux:

split-window [-dhvP] [-c start-directory] [-l size | -p percentage] [-t target-pane] [shell-command] [-F format] (alias: splitw)
Create a new pane by splitting target-pane: -h does a horizontal split and -v a vertical split; if neither is specified, -v is assumed. The -l and -p options specify the size of the new pane in lines (for vertical split) or in cells (for horizontal split), or as a percentage, respectively. All other options have the same meaning as for the new-window command.

You could use it from your current window by entering command mode, Ctrlb,: and entering at the prompt:

splitw -v -p 50 'your command'

This would split your current window vertically in half (50 percent) with your command executed in it.

If you use this command frequently, you can always bind it to a key sequence, eg.,

bind '~' split-window -v -p 50 'htop'
  • This fails to address the question. I know how to split windows, but I want to run the same command as the current window in the new pane. I don't want to type the command again. – PAG Feb 6 '13 at 8:40
  • The see Chris' answer. And, for the record, it did address the question as it was originally asked: it is not my problem if your question was phrased ambiguously. But thanks for the generous feedback. – jasonwryan Feb 6 '13 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.