1

I'd like to start tmux from terminal, split it window and execute in the splits some commands. Furthermore, I'd like to did with bash script, that I start from terminal. Now, I've been able to start tmux only.

#!/bin/sh

tmux

# How to split tmux window there, and start commands in splits?
Loom
  • 9,768
  • 22
  • 60
  • 112
  • possible duplicate of [Bash scripts with tmux to launch a 4-paned window](http://stackoverflow.com/questions/5447278/bash-scripts-with-tmux-to-launch-a-4-paned-window) – fredtantini Dec 10 '14 at 09:34
  • 1
    I wrote a tool **retmux** https://github.com/sk1418/retmux it can restore your tmux sessions/layouts/path in window/even text on screen easily. just `retmux -r` but executing command is not supported. You may want to take a look. – Kent Dec 10 '14 at 10:04

1 Answers1

4

There is a script started tmux, splitted for to panes and started ls in the left pane and top in the right one.

#!/bin/sh

tmux new-session -d -s main ;
tmux split-window -h ;
tmux select-pane -L
tmux send-keys -t main 'ls' C-m
tmux select-pane -R
tmux send-keys -t main 'top' C-m
tmux attach-session -d -t main 
Loom
  • 9,768
  • 22
  • 60
  • 112