Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a tmux window that I've open 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.

share|improve this question
up vote 2 down vote accepted

With tmux 1.7 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 the command used to start the current pane.
  • 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.

share|improve this answer
+1 for the pane_start_command: thanks. – jasonwryan Feb 6 '13 at 4:56
Glad I chose to go with 1.7. I'll try this later today, thanks! – PAG Feb 6 '13 at 8:42
Worked perfectly – PAG Feb 6 '13 at 18:11
Under 1.9 this has now been simplified to bind-key S run-shell "tmux split-window \"#{pane_start_command}\"" – PAG Jul 8 '15 at 9:03

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'
share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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