tmux-powerline-theme
tmux-powerline-theme copied to clipboard
Powerline theme for Tmux.
Tmux Powerline theme

(March 2016) Rewritten with support for Tmux Plugin Manager (optional), and avoids an ugly race condition workaround used in the previous version. Upgrade!
Features
- 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.
Issues
- Doesn't check Tmux version before executing commands, resulting in error messages at startup. (#2)
Alternatives
- More powerful, but with dependencies: https://github.com/powerline/powerline
Install
Tmux Plugin Manager (TPM)
- Use Tmux Plugin Manager.
- Add to your
.tmux.conf:set -g @plugin 'jooize/tmux-powerline-theme' - Hit
^B Iinside Tmux to make TPM install it.
Load from shell
- Save
powerline-theme.tmuxsomewhere. - Run in a shell:
sh powerline-theme.tmux
Manual install in tmux.conf
- Save
powerline-theme.tmuxto$HOME/.tmux/tmux-powerline-theme/powerline-theme.tmux - Put in your
tmux.conf:run-shell "$HOME/.tmux/tmux-powerline-theme/powerline-theme.tmux"
Configure
All paths assume installation by Tmux Plugin Manager.
$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux
Enable Powerline symbols
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"'
Symbol alternatives
| 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.
Compact mode
Environment variables. Run in shell either before starting Tmux or execute powerline-theme.tmux afterward to apply.
Compact current window
export TMUX_POWERLINE_COMPACT_CURRENT=on
Compact other windows
export TMUX_POWERLINE_COMPACT_OTHER=on
Flag
export TMUX_POWERLINE_FLAG=on
Symbols
export TMUX_POWERLINE_SYMBOLS="powerline"
Suggestions
Toggle key for symbols
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"'
Enable and disable keys for symbols
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"
Change symbols manually while Tmux is running
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.
Attach Tmux on device without Powerline font
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"