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.

3 Answers 3


#{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.

  • I do not get a plain login shell if the command string was empty; I get a blank pane instead. (tmux v3.0a) Feb 14, 2022 at 17:05

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, 2013 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, 2013 at 8:58

Not sure if this changed across tmux versions, but for me (tmux 3.0a), I find the accepted answer opens a completely blank pane, not a new shell, if run on a pane with no start command. This worked for me instead:

bind C run-shell "CMD=\"#{pane_start_command}\" ; tmux split-window -v \${CMD:+ -c \"#{pane_current_path}\" \"\$CMD\"}"

This leverages alternate value substitution to drop off the argument entirely if it would be empty (thanks to John Kugelman's answer for this approach).

The additional -c \"#{pane_current_path}\" runs the command in the same directory as the current pane, which is important for my workflows. If you want that on all new panes, not just ones running commands, move the fragment outside of the enclosing \${...}.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .