Sep 29, 2014

tmux - tmuxinator => Terminal Multiplexer as alternative to screen and a nice configuration tool for the session.

During some time I used screen, which allows to open multiple shells in one
terminal, detach from the session and let the session continue in the back-
ground.

Some time ago I switched to tmux, as an alternative which is highly
customizeable.

You can switch between different sessions by using the binding key.
In my case <Ctrl>-<a>-<s>.

to start a new session inside of tmux use <Ctrl>-<a>-<:> new-session

You can cycle through the session with <Ctrl>-<a>-<(> or <Ctrl>-<a>-<s>


There is an other tool named tmuxinator. On Fedora 20 you can install it
with sudo yum install tmuxinator


tmuxinator new <Name> or mux new <Name> starts the configuration
of a session, where you can configure the setup of the session.


Here is a config:

# ~/.tmuxinator/TT.yml

name: TT
root: ~/entw/dev

# Optional tmux socket
# socket_name: foo

# Runs before everything. Use it to start daemons etc.
pre: docker start lxewerMysql; sleep 10; updateDockerIp.sh lxewerMysql

# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions.
pre_window: . /home/ewer/prod/TTenv.bashrc

# Pass command line options to tmux. Useful for specifying a different tmux.conf.
# tmux_options: -f ~/.tmux.mac.conf

# Change the command to call tmux.  This can be used by derivatives/wrappers like byobu.
# tmux_command: byobu

windows:
  - JBOSS:
      layout: main-hoirzontal
      panes:
        - sleep 5; cd $JBOSS_HOME; bin/standalone.sh
        - cd $JBOSS_HOME
  - COMPILE:

This example starts my mysqldatabase docker container, updates the IP
adress in my local hosts file.

The start directory is set to the value of root: ~/entw/dev.

On every window the environment the file from pre_window:is sourced in.

The first window named JBOSS has 2 panes where in the  first JBOSS is
started, with a sleep to let docker start the database container, which is
referenced by the datasources in the JBOSS Appserver.

The second pane just changes to the HOME of the jboss installation.

On the second window the directory is set to the dev Directory set on the
beginning of the config.

Here you can create multiple sessions. with mux <sessionname> and
switch between the sessions as describe above. The other session are
running in the background.