Terminal multiplexers allow you to view multiple separate terminal sessions within a single terminal window. Tmux is my terminal multiplexer of choice, as it has more features than the 'original multiplexer' GNU Screen. The default setup gives you some information, but its appearance is, well...
Fortunately you can theme, or customize pretty much everything: From the colors to the information being shown in the status bar.
In order to make it easier to theme tmux, I split the tmux configuration file
into two separate files. One file contains the main configuration
(
~/.tmux.conf
), and another file contains only theming (visual)
variables (
~/.tmux.THEMENAME.theme
). This setup makes it easier to
switch different themes, without changing the main tmux configuration file.
As I wanted to automatically load a theme based on a shell environment variable, I added a small piece of code to the main tmux configuration file. This executes a shell command, which in turn loads the correct theme file.
run-shell "tmux source-file ~/.tmux.\${TMUX_THEME:-default}.theme"
The theme file is loaded dynamically, based on the environment variable
$TMUX_THEME
. If the environment variable is not set or empty, then the
default theme is loaded:
~/.tmux.default.theme
.
Loading a different theme is easy to do from within tmux using the
source-file
:
tmux source-file ~/.tmux.THEMENAME.theme
My main tmux configuration file has a shortcut binding ( r ) to quickly reload a new configuration. This means that changes to the current theme can be applied and viewed easily.
bind r source-file ~/.tmux.conf \; display-message "tmux configuration file
reloaded..."
Tmux can be found at https://github.com/tmux/tmux , and my personal tmux configuration and theme files can be found https://github.com/PeterMosmans/dotfiles/blob/master/.tmux.conf and https://github.com/PeterMosmans/dotfiles/blob/master/.tmux.dracula.conf
Comments
comments powered by Disqus