I want a new session with two windows named mutt and offlineimap. the offlineimap window should be split into two using two different offlineimap instances (with different profiles).

tmux new-session -d -s mail -n mutt mutt
tmux new-window -d -t mail -n offlineimap "offlineimap -c ~/.dotfiles/mutt/dev.offimap"
tmux split-window -d -v -t mail "offlineimap -c ~/.dotfiles/mutt/trash.offimap"

just creates an mutt window, but no offlineimap windows. => What is wrong with that code?


When I change the content of the "" to sleep 1000 it works.


I've found out the second tmux window exits instantaneously after its creation, because it "uses the same metadata as the first offlineimap"

1 Answer 1


You wrote:

tmux new-session -d -s mail -n mutt mutt
tmux new-window -d -t mail -n offlineimap "offlineimap -c ~/.dotfiles/mutt/dev.offimap"
tmux split-window -d -v -t mail "offlineimap -c ~/.dotfiles/mutt/trash.offimap"

Try this instead, write this into a tmux_mail.sh or whatever you wish to name it:


tmux \
    -v \
    new-session \
        -d \
        -s mail \
        -n mutt \
        mutt \
    \; \
    new-window \
        -d \
        -n offlineimap \
        "offlineimap -c ~/.dotfiles/mutt/dev.offimap" \
    \; \
    split-window \
        -d \
        "offlineimap -c ~/.dotfiles/mutt/trash.offimap" \
    \; \

Once saved and made executable, run it on your command prompt to enjoy your new tmux mail session:

$ ./tmux_mail.sh


  • \; to make each new-window or split-window arguments part of a single continuous tmux command
  • so we omit -t as you don't need -t to specify target session when all this is specified as part of one single tmux command
  • every line except the last uses bash line continuation \ (a backslash followed by a space, followed by a line return) to continue the lines of the command we want bash to run, while allowing us to write the command fully yet with nearly one option per line, for easier reading and clarity which may help you maintain this script in the long run
  • -v for verbose logging needs to be specified in the beginning, per the syntax synopsis in man tmux
  • the -d is to detach so it does not carry out the default behavior of attaching to current terminal right away, not until we have a chance to fully specify the options we want
  • thus in the end when done with all our options that we want tmux to do, we have to attach to actually see the final result on our terminal
  • note that if a program is non-interactive, just runs and exits such as echo, then that will similarly happen in tmux, it would just run the program and then close the window when the program exits

So as long as your mutt and offlineimap commands actually work and don't quit right away normally, and work fine outside of tmux, then with these commands they should work in tmux, creating the tmux session you wanted.

You must log in to answer this question.

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