(March 2016) Rewritten with support for Tmux Plugin Manager (optional), and avoids an ugly race condition workaround used in the previous version. Upgrade!
- Colors chosen to degrade gracefully (256 → 16 → 2), and shows flag automatically if initialised with fewer than 16 colors supported.
- Supports new and old Powerline glyphs, but defaults to no special symbols.
- Doesn't check Tmux version before executing commands, resulting in error messages at startup. (#2)
- More powerful, but with dependencies: https://github.com/powerline/powerline
- Use Tmux Plugin Manager.
- Add to your
.tmux.conf
:set -g @plugin 'jooize/tmux-powerline-theme'
- Hit
^B I
inside Tmux to make TPM install it.
- Save
powerline-theme.tmux
somewhere. - Run in a shell:
sh powerline-theme.tmux
- Save
powerline-theme.tmux
to$HOME/.tmux/tmux-powerline-theme/powerline-theme.tmux
- Put in your
tmux.conf
:run-shell "$HOME/.tmux/tmux-powerline-theme/powerline-theme.tmux"
All paths assume installation by Tmux Plugin Manager.
$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux
If you don't want Powerline symbols, simply load the theme.
#
# Powerline theme
#
# Enable Powerline symbols (unless already specified otherwise in environment)
if-shell ': ${TMUX_POWERLINE_SYMBOLS?}' '' 'set-environment -g TMUX_POWERLINE_SYMBOLS "powerline"'
# Toggle between Powerline and Unicode symbols with ^B P
bind-key P if-shell 'test $(echo "${TMUX_POWERLINE_SYMBOLS}") = "unicode"' 'set-environment -g TMUX_POWERLINE_SYMBOLS "powerline" ; run-shell "$HOME/.tmux/plugins/powerline-theme/powerline-theme.tmux"' 'set-environment -g TMUX_POWERLINE_SYMBOLS "unicode" ; run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux"'
Option | Explanation |
---|---|
powerline |
Use the new Powerline symbols. (January 2013 or later) |
vim-powerline |
Use the old Powerline symbols from the now deprecated Lokaltog/vim-powerline project. |
unicode |
Use Unicode symbols. (default) |
ascii |
Use ASCII symbols. |
none |
No symbols. |
Both unicode
and ascii
effectively mean no symbols at this time.
Environment variables. Run in shell either before starting Tmux or execute powerline-theme.tmux
afterward to apply.
export TMUX_POWERLINE_COMPACT_CURRENT=on
export TMUX_POWERLINE_COMPACT_OTHER=on
export TMUX_POWERLINE_FLAG=on
export TMUX_POWERLINE_SYMBOLS="powerline"
Switch between two sets of symbols with ^B P
by putting this in your .tmux.conf
.
# Toggle between Unicode and new Powerline symbols
bind-key P if-shell 'test $(echo "${TMUX_POWERLINE_SYMBOLS}") = "unicode"' 'set-environment -g TMUX_POWERLINE_SYMBOLS "powerline" ; run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux"' 'set-environment -g TMUX_POWERLINE_SYMBOLS "unicode" ; run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux"'
Add these lines to your .tmux.conf
and replace the brackets with your preferred keys.
bind-key <enable_key> set-environment -g TMUX_POWERLINE_SYMBOLS "powerline" \; run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux"
bind-key <disable_key> set-environment -g TMUX_POWERLINE_SYMBOLS "unicode" \; run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux"
tmux set-environment -g TMUX_POWERLINE_SYMBOLS "powerline"
tmux run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux"
Or replace tmux
with pressing ^B :
to use Tmux's command line.
Run the following in a shell, then optionally specify its location as command to run on connect in your SSH client.
mkdir -p "$HOME/Executables"
cat << 'EOF' > "$HOME/Executables/TmuxAttachMobile.sh"
#!/bin/sh
# Set desired symbols.
tmux set-environment -g TMUX_POWERLINE_SYMBOLS "unicode"
# Run Powerline theme again to apply.
tmux run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux"
# Attach Tmux.
tmux attach
EOF
chmod +x "$HOME/Executables/TmuxAttachMobile.sh"