When we do C+a or whatever key binding is and followed by " or % then tmux split this pane into horizontally or vertically.

What I want is whenever I press C+a+% or C+a+" then it should execute some command.

e.g. C+a+% should split the pane and execute command ls and C+a+" should split the pane and execute the command ls in the same pane.

You can assume always I want to execute the same command e.g ls.

How to achieve this in tmux using tmux.conf file?

  • Do you want the command to be run as if you typed it in the new terminal/pane, or do you want to capture output in copy mode and then discard it once the command has run? Aug 1, 2016 at 10:14
  • I don't want to capture o/p of command, I want to run another command which doesn't produce any output.
    – sonus21
    Aug 1, 2016 at 10:33

1 Answer 1


To split the widow horizontally and make the command ls -al run as if you typed it in the new terminal/pane

bind-key '"' split-window \; send-keys "ls -al" Enter

for a vertical split

bind-key % split-window -h \; send-keys "ls -al" Enter

To split horizontal and run the command in the background then capture the output in copy mode

bind-key " split-window \; run-shell "ls -al"

The \; is used to quote the " intended for the split-window command from the bind-key command.

  • This seems not to be working, specially for ".
    – sonus21
    Aug 1, 2016 at 10:42
  • For the doublequote version you need to singlequote the character, i.e. it begins bind-key '"' split-window....
    – meuh
    Aug 1, 2016 at 11:52
  • @meuh ,thanks, I tested the command on my computer by binding , (I didn't want to break my " binding) the command worked for me, so I assumed it would be good to post! Aug 1, 2016 at 12:03
  • Interestingly after adding bind-key '"' split-window \; send-keys "ls -al" Enter and bind-key % split-window \; send-keys "ls -al" Enter both splits horizontally pane instead of splitting horizontally and vertically.
    – sonus21
    Aug 1, 2016 at 12:53
  • @sonukumar: for horizontal split its missing the -h argument: have a look into man tmux, for the split-window -h: -h does a horizontal split and -v a vertical split; if neither is specified, -v is assumed
    – zipizap
    Dec 26, 2017 at 23:31

You must log in to answer this question.

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