• Stars
    star
    3,372
  • Rank 13,264 (Top 0.3 %)
  • Language
    Shell
  • License
    BSD 3-Clause "New...
  • Created over 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚡️ A tmux plugin giving you a hackable status bar consisting of dynamic & beautiful looking powerline segments, written purely in bash.

log

Empowering your tmux (status bar) experience!


GitHub Stars GitHub Forks

SLOC Number of programming languages used Top programming languages used Open issues Closed issues Closed PRs License OSS Lifecycle Latest tag

Contributors including these top contributors:

Intro

tmux-powerline is a tmux tpm plugin that gives you a slick and hackable powerline status bar consisting of segments. It's easily extensible with custom segments and themes. The plugin itself is implemented purely in bash thus minimizing system requirements. However you can make segments in any language you want (with a shell wrapper).

Some examples of segments available that you can add to your tmux status bar are (full list here):

  • LAN & WAN IP addresses
  • Now Playing for MPD, Spotify (GNU/Linux native or wine, OS X), iTunes (OS X), Rhythmbox, Banshee, MOC, Audacious, Rdio (OS X), cmus, Pithos and Last.fm (last scrobbled track).
  • New mail count for GMail, Maildir, mbox, mailcheck, and Apple Mail
  • GNU/Linux and Macintosh OS X battery status (uses richo/dotfiles/bin/battery)
  • Weather in Celsius, Fahrenheit and Kelvin using Yahoo Weather
  • System load, cpu usage and uptime
  • Git, SVN and Mercurial branch in CWD
  • Date and time
  • Hostname
  • tmux info
  • CWD in pane
  • Current X keyboard layout
  • Network download/upload speed
  • Earthquake warnings

Screenshots

Full screenshot

Full screenshot

left-status

Current tmux session, window and pane, hostname and LAN & WAN IP address.

left-status

right-status

New mails, now playing, average load, weather, date and time.

right-status

Now I've read my inbox so the mail segment disappears!

right-status, no mail

After pausing the music there's no need for showing the Now Playing segment anymore. Also the weather has become much nicer!

right-status, no mpd

Laptop mode: a battery segment.

right-status, weather and battery

Requirements

Requirements for the lib to work are:

  • tmux -V >= 2.1
  • bash --version >= 3.2 (Does not have to be your default shell.)
  • A patched font. Follow instructions at Powerline Installation or download a new one. However you can use other substitute symbols as well; see config.sh.

Segment Requirements

Some segments have their own requirements. If you enable them in your theme, make sure all requirements are met for those.

  • wan_ip.sh, now_playing.sh (last.fm), weather_yahoo.sh: curl, bc
  • now_playing.sh
  • xkb_layout.sh: X11, XKB
  • mailcount.sh (gmail): wget, (mailcheck): mailcheck.
  • ifstat.sh: ifstat (there is a simpler segment not using ifstat but samples /sys/class/net)
  • tmux_mem_cpu_load.sh: tmux-mem-cpu-load
  • rainbarf.sh: rainbarf
  • weather.sh: GNU grep with Perl regexp enabled (FreeBSD specific), jq for yrno weather API.

FreeBSD specific requirements

Preinstalled grep in FreeBSD doesn't support Perl regexp. Solution is rather simple -- you need to use textproc/gnugrep port instead. You also need to make sure, that it has support for PCRE and is compiled with --enable-perl-regexp flag.

Installation

  1. Install tpm and make sure it's working.
  2. Install tmux-powerline as a plugin by adding a line to tmux.conf:
     set -g @plugin 'erikw/tmux-powerline'
    
  3. Install the plugin with <prefix>I, unless you changed tpm's keybindings.
    • The default powerline should already be visible now!
  4. Continue to the Configuration section below.

Note that tpm plugins should be at the bottom of you tmux.conf. This plugin will then override some tmux settings like status-left, status-right etc. If you had already set those in your tmux config, it is a good opportunity to remove or comment those out. Take a look at main.tmux for exactly which settings are overridden.

Configuration

tmux-powerline stores the custom config, themes and segments at $XDG_CONFIG_HOME/tmux-powerline/.

To make the following example easier, let's assume the following:

  • $XDG_CONFIG_HOME has the default value of ~/.config
  • tmux-powerline was installed to the XDG path ~/.config/tmux/plugins/tmux-powerline

Adapt the commands below if your paths differs from this.

Config file

Start by generating your own configuration file:

~/.config/tmux/plugins/tmux-powerline/generate_rc.sh
mv ~/.config/tmux-powerline/config.sh.default ~/.config/tmux-powerline/config.sh
$EDITOR ~/.config/tmux-powerline/config.sh

Go through the default config and adjust to you needs!

Custom theme

The theme is specified by setting the environment variable $TMUX_POWERLINE_THEME in the config file above. It will use a default theme and you probably want to use your own. The default config have set the custom theme path to be ~/.config/tmux-powerline/themes/.

Make a copy of the default theme and make your own, say my-theme:

mkdir -p ~/.config/tmux-powerline/themes
cp ~/.config/tmux/plugins/tmux-powerline/themes/default.sh ~/.config/tmux-powerline/themes/my-theme.sh
$EDITOR ~/.config/tmux-powerline/themes/my-theme.sh.default

Remember to update the configuration file to use the new theme by setting TMUX_POWERLINE_THEME=my-theme

Custom segments

In the same was as themes, you can create your own segments at TMUX_POWERLINE_DIR_USER_SEGMENTS which defaults to ~/.config/tmux-powerline/segments.

To get started, copy an existing segment that is similar to the segment that you want to create.

mkdir -p ~/.config/tmux-powerline/segments
cp ~/.config/tmux/plugins/tmux-powerline/segments/date.sh ~/.config/tmux-powerline/themes/my-segment.sh
$EDITOR ~/.config/tmux-powerline/themes/my-segment.sh.default

Now you can add my-segment to your own theme!

Also see How to make a segment below for more details.

Debugging

Some segments might not work on your system for various reasons such as missing programs or different versions not having the same options. To find out which segment is not working it may help to enable the debug setting in ~/.tmux-powerlinerc. However this may not be enough to determine the error so you can inspect all executed bash commands (will be a long output) by doing

bash -x powerline.sh (left|right)

To debug smaller portions of code, say if you think the problem lies in a specific segment, insert these lines at the top and bottom of the relevant code portions e.g. inside a function:

set -x
exec 2>/tmp/tmux-powerline.log
<code to debug>
set +x

and then inspect the outputs like

less /tmp/tmux-powerline.log
tail -f /tmp/tmux-powerline.log # or follow output like this.

You can also enable the debug mode in your config file. Look for the TMUX_POWERLINE_DEBUG_MODE_ENABLED environment variable and set it to true.

If you can not solve the problems you can post an issue and be sure to include relevant information about your system and script output (from bash -x) and/or screenshots if needed. Be sure to search in the resolved issues section for similar problems you're experiencing before posting.

Common problems

VCS_branch / PWD is not updating

The issue is probably that the update of the current directory in the active pane is not updated correctly. Make sure that your PS1 or PROMPT variable actually contains the line from the installation step above by simply inspecting the output of echo $PS1. You might have placed the PS1 line in you shell configuration such that it is overwritten later. The simplest solution is to put it at the very end to make sure that nothing overwrites it. See issue #52.

Nothing is displayed

You have edited ~/.tmux.conf but no powerline is displayed. This might be because tmux is not aware of the changes so you have to restart your tmux session or reloaded that file by typing this on the command line (or in tmux command mode with prefix :)

tmux source-file ~/.tmux.conf

Multiple lines in bash or no powerline in zsh using iTerm (macOS)

If your tmux looks like this then you may have to in iTerm uncheck [Unicode East Asian Ambiguous characters are wide] in Preferences -> Settings -> Advanced.

Hacking

This project can only gain positively from contributions. Fork today and make your own enhancements and segments to share back! If you'd like, add your name and E-mail to AUTHORS before making a pull request so you can get some credit for your work :-)

How to make a segment

If you want to (of course you do!) send a pull request for a cool segment you written make sure that it follows the style of existing segments, unless you have good reason for it. Each segment resides in the segments/ directory with a descriptive and simple name. A segment must have at least one function and that is run_segment which is like the main function that is called from the tmux-powerline lib. What ever text is echoed out from this function to stdout is the text displayed in the tmux status bar. If the segment at a certain point does not have anything to show, simply don't echo anything out and the segment will be hidden. A successful execution of the run_segment function should return an exit code of 0. If the segment failed to execute in a fatal way return a non-zero exit code so the user can pick up the error and fix it when debug mode is on (e.g. missing program that is needed for the segment).

Usage of helper function to organize the work of a segment is encourage and should be named in the format __helper_func. If a segment has settings it should have a function generate_rc which outputs default values of all settings and a short explanation of the setting and its values. Study e.g. segments/now_playing.sh to see how it is done. A segment having settings should typically call a helper function __process_settings as the first statement in run_segment that sets default values to the settings that has not been set by the user.

Also, don't use bash4 features as requiring bash4 complicates installation for macOS user quite a bit. Use tabs for indentation (discussion),

More tmux plugins

I have another tmux plugin that might interest you:

  • tmux-dark-notify - A plugin that make tmux's theme follow macOS dark/light mode.

More Repositories

1

vim-keybindings-everywhere-the-ultimate-list

The ultimate list of which programs support Vim-like keybindings natively, or how they can be added with extensions. A collaborative project.
Shell
838
star
2

restic-automatic-backup-scheduler

Automatic restic backup using Backblaze B2 storage and either Linux systemd timers, macOS LaunchAgent, Windows ScheduledTask or simply cron.
Shell
485
star
3

dotfiles

🏠 My personal dotfiles, following the XDG Base Directory Standard.
Shell
44
star
4

taiga-stats

Generate statistics from Taiga and produce burnup diagrams, CFDs, dependency graphs and more.
Python
40
star
5

ewxb-gcc-cross-compiler-builder

A script for building a full GCC + glibc toolchain from scratch (with Go support via gccgo) in multiple stages.
Shell
19
star
6

jekyll-glossary_tooltip

Jekyll plugin providing a glossary liquid tag that will show a tooltip of a term definition.
Ruby
17
star
7

advent-of-code-solutions

My solutions to puzzles at https://adventofcode.com/
Ruby
15
star
8

tmux-dark-notify

A plugin that make tmux's theme follow macOS dark/light mode.
Shell
10
star
9

nestedtext-ruby

A ruby implementation of NestedText https://nestedtext.org/
Ruby
7
star
10

jekyll-google_search_console_verification_file

Jekyll plugin that generates a Google Search Console verification file from configuration.
Ruby
7
star
11

cs142a-labs

Projects in CS142A Interpreters and Compilers at University of California, Irvine
Java
5
star
12

exsportify

Spotify Playlist Exporter: Ideal for (cron'd) backups to different formats.
C++
4
star
13

cs143-project

Projects in CS143 Principles of Operating Systems at University of California, Irvine
HTML
3
star
14

jekyll-utility-scripts

Jekyll utility scripts for development
Shell
2
star
15

templates

Templates that I re-use for new projects.
TeX
2
star
16

homebrew-tap

Erik Westrup's Homebrew Tap
Ruby
2
star
17

github-stats

Created from https://github.com/jstrieb/github-stats
Python
1
star
18

eit060-project2

Second project in the course EIT060 Computer Security at Lund University.
Java
1
star