Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
The Definitive Guide to Customizing the Tmux Status Line
I assume you already have a .tmux.conf file set up that is already being used. If not first look up setting up .tmux.conf or something similar.
Step 1: How to Change the Status Line
set -g status-left <options>set -g status-right <options>
Replace <options> with a string of all the options you want. Background color can be set using #[bg=colour*] where * is some number 0–255 for terminals with 256 color support. To change the foreground color (text color) it’s just #[fg=colour*] (Again replacing * with a number between 0 and 255).
To view all 255 colors at once see the comment of this stack overflow answer
One of the first things I wanted to do was to add the date and time in the status line. Simple enough right. Here is a complete list of options https://linux.die.net/man/3/strftime or for a shorter more readable list see part of my .tmux.conf https://github.com/sbernheim4/dotfiles/blob/master/.tmux.conf#L59.
Adding %H:%M in the <options> string will show the current time in a 24 hour format without seconds (something like 15:38).
Step 2: Tmux Specific Values
Tmux has its own set of values that stand for different things. For example #H refers to the hostname of the computer you are currently on and #S to the index of the current session. For the complete list of options go here and search for this phrase “Character pair Replaced with”
Step 3: Using Bash Commands to Display Cool Stuff
The last key step is being able to display cool information using bash commands. This can include things like battery percentage, current song playing etc. To do this you first have to find a bash script or command that gives you the output you want. For example, I display the current battery percentage using the following command:
pmset -g batt | grep [0–9][0–9]% | awk ‘NR==1{print $3}’ | cut -c 1–3
Note: This only works for Macs since pmset is a mac specific terminal command.
I have a file stored on my computer called battery.sh. The file is two lines long. Line 1 is the bash shebang (#!/bin/bash) and line 2 is the command above. To show the battery in the status line, in my .tmux.conf in <options> I have
#(path/to/battery.sh)
(Pro Tip: adding an emoji like: ♥ before the # will display it as ♥ 64% in the status line which looks cooler than just 64%)
Step 4: Plugins
Alright so these aren’t really plugins so much as they are scripts that other people have already written. Check out https://github.com/jdxcode/tmux-spotify-info for getting the current playing Spotify song, this again is mac only because the developer wrote this script in apple script. But the point is you can find scripts that other people already wrote for your environment and easily add them to your status line.
Step 5: Customizing the Windows
Hopefully you already know the difference between sessions, windows, and panes. if not, quickly read up on that.
Point is, beyond the left and right side of the status line you can also customize how the windows are displayed in the status with:
set -g window-status-format <options>
where <options> is the same configuration as it was way above. You also can customize the display for the current window you are on with:
set -g window-status-current-format <options>
See this site again and search “Character pair Replaced with” to view some specially reserved Tmux commands for windows. You can also then customize the separators that are used to show the difference between windows. Customizing the separators may require a patched font to display certain characters. A quick google search of patched fonts should get you some good results. For cool unicode character separators (still might require a patched font even though they’re unicode) check out this site.
hint: try searching stuff like left triangle
Thanks for reading. View my own .tmux.conf
Customizing Tmux was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.