Skip to content

rintaun/tmux-powerline

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tmux-powerline

This is a set of scripts for making a nice and dynamic tmux statusbar consisting of segments. This is much like Lokaltog/vim-powerline but for tmux.

The following segments exists for now:

  • 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 and Last.fm (last scrobbled track).
  • New mail count for GMail, Maildir, mbox 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.

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 NP anymore. Also the weather has become much nicer!

right-status, no mpd

Remaining battery.

right-status, weather and battery

Requirements

Requirements for the lib to work are:

Segment Requirements

Requirements for some segments. You only need to fulfill the requirements for those segments you want to use.

  • wan_ip.sh, np_lastfm.sh, weather_yahoo.sh: curl, bc
  • np_mpd.sh: libmpdclient
  • xkb_layout.sh: X11, XKB
  • mail_count_gmail.sh: wget.
  • 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

OS X specific requirements

You still need to follow the first part of these instructions even if you are running zsh or something else as your default shell!

tmux-powerline uses associative arrays in bash, which were added in bash version 4.0. OS X Lion ships with an antiquated version of bash ( run bash --version to see your version). In order to use tmux-powerline, you need to install a newer version of bash, fortunately, brew makes this very easy. If you don't have brew, install it. Alternatively the older MacPorts can be used. Then follow these steps:

$ brew install bash

If you're using something other than bash (or if you don't want this newer version of bash as your default shell) you should be done now. If something seems broken, try following the last two steps and see if it helps:

$ sudo bash -c "echo /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash >> /private/etc/shells"
$ chsh -s /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash

The first command installs bash through brew, the second registers the new shell with the system and the third changes to the new shell for your user. If you later upgrade bash through brew, don't forget to do the last two steps again with the new version number. After doing the above and restarting your terminal, running echo $SHELL should result in the following:

$ echo $SHELL
/usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash

The grep tool is outdated on OS X 10.8 Mountain Lion so you might have to upgrade it. Unfortunately the main homebrew repo does not contain grep so use the following command to get the lastest version.

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/grep.rb

Installation

Just check out the repository with:

$ cd ~/some/path/
$ git clone git://github.com/erikw/tmux-powerline.git

Now edit your ~/.tmux.conf to use the scripts:

set-option -g status on
set-option -g status-interval 2
set-option -g status-utf8 on
set-option -g status-justify "centre"
set-option -g status-left-length 60
set-option -g status-right-length 90
set-option -g status-left "#(~/path/to/tmux-powerline/powerline.sh left)"
set-option -g status-right "#(~/path/to/tmux-powerline/powerline.sh right)"

Set the maximum lengths to something that suits your configuration of segments and size of terminal (the maximum segments length will be handled better in the future). Segments needs to use different tools or options depending on platform. Currently there is only a distinction between Linux systems and OS X systems. config.sh tries to detect what machine you're on with uname. If needed you can override this setting with the PLATFORM variable there (or wherever you want to define it).

Some segments e.g. cwd and cvs_branch needs to find the current working directory of the active pane. To achieve this we let tmux save the path each time the shell prompt is displayed. Put the line below in your ~/.bashrc or where you define you PS1 variable. zsh users can put it in e.g. ~/.zshrc and may change PS1 to PROMPT (but that's not necessary).

PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#D" | tr -d %) "$PWD")'

You can toggle the visibility of the statusbars by adding the following to your ~/.tmux.conf:

bind C-[ run '~/path/to/tmux-powerline/mute_statusbar.sh left'		# Mute left statusbar.
bind C-] run '~/path/to/tmux-powerline/mute_statusbar.sh right'		# Mute right statusbar.

Configuration

The default segments that are shown are defined in themes/default.sh. You will probably want to change those to fit your needs. To do so you can edit that file directly but preferable, for easier updating of the repo, you can make a copy and edit that one.

$ cp themes/default.sh themes/mytheme.sh
$ $EDITOR themes/mytheme.sh

Now generate a default configuration file by doing

$ ./generate_rc.sh
$ mv ~/.tmux-powerlinerc.default ~/.tmux-powerlinerc
$ $EDITOR ~/.tmux-powerlinerc```

and editing theme to use and values for segments you want to use.

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 command (will be a long output) by doing

$ bash -x powerline.sh (left|right)

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.

Common problems

VCS_branch 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.

Hacking

This project can only gain positively from contributions. Fork today and make your own enhancements and segments to share back!

About

Statusbar configuration for tmux that looks like vim-powerline and consist of dynamic segments.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 88.8%
  • C 11.2%