We use foreman
to start all necessary processes for an application, which are declared in a Procfile
. This is very convenient, but the outputs of all processes get merged together. Especially while debugging you might not want other processes to flood your screen with their log messages.
The following setup allows you to start Terminator in a split view with the Rails server running in the left pane and all remaining processes running via foreman in the right pane. It was heavily inspired by this card.
This terminator.config
describes the split view layout and which command to run in each pane. Put it into the application's root directory:
[global_config]
suppress_multiple_term_dialog = True
[keybindings]
[profiles]
[[default]]
cursor_color = "#aaaaaa"
font = Ubuntu Mono 14
use_system_font = False
[layouts]
[[PROJECT_NAME]]
[[[child0]]]
type = Window
parent = ""
position = 3458:171
maximised = True
fullscreen = False
title = PROJECT_NAME
last_active_window = True
[[[child1]]]
type = HPaned
parent = child0
ratio = 0.5
[[[terminal2]]]
type = Terminal
parent = child1
profile = default
command = env startup_cmd="bundle exec rails server" startup_attrs="-p 3000" bash
[[[terminal3]]]
type = Terminal
parent = child1
profile = default
command = 'env startup_cmd="foreman start" startup_args="-f Procfile.dev -m all=1,web=0" bash'
[plugins]
To make the environment variables work, put the following into your .bashrc
:
[[ $startup_cmd ]] && { declare +x $startup_cmd; history -s "$startup_cmd $startup_args"; eval "$startup_cmd $startup_args"; }
This also puts the commands into their pane's history before executing them. This allows you to quickly restart them even if a process terminated with a non-zero exit code.
Finally, put the following into bin/term
to comfortably start Terminator with the config above:
#!/usr/bin/env bash
terminator -u -g terminator.config -l PROJECT_NAME -p ${1:-default}
If contributors on your project prefer different profile settings, they can simply add their own profile in terminator.config
under [profiles]
(make sure to not delete the default profile) and then run bin/term <profile_name>
.