├── README.md ├── demo.sh └── powerline-theme.tmux /README.md: -------------------------------------------------------------------------------- 1 | Tmux Powerline theme 2 | ==================== 3 | 4 | ![](https://i.imgur.com/oqLvFf7.gif) 5 | 6 | (March 2016) Rewritten with support for [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (optional), and avoids an ugly race condition workaround used in the [previous version](https://github.com/jooize/tmux-powerline-theme/tree/native). Upgrade! 7 | 8 | ## Features 9 | 10 | - Colors chosen to degrade gracefully (256 → 16 → 2), and shows flag automatically if initialised with fewer than 16 colors supported. 11 | - Supports new and old Powerline glyphs, but defaults to no special symbols. 12 | 13 | ## Issues 14 | 15 | - Doesn't check Tmux version before executing commands, resulting in error messages at startup. ([#2](https://github.com/jooize/tmux-powerline-theme/issues/2)) 16 | 17 | ## Alternatives 18 | 19 | - More powerful, but with [dependencies](https://powerline.readthedocs.io/en/latest/installation.html): https://github.com/powerline/powerline 20 | 21 | ## Install 22 | 23 | ### Tmux Plugin Manager (TPM) 24 | 25 | 1. Use [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm). 26 | 2. Add to your `.tmux.conf`: `set -g @plugin 'jooize/tmux-powerline-theme'` 27 | 3. Hit `^B I` inside Tmux to make TPM install it. 28 | 29 | ### Load from shell 30 | 31 | 1. Save `powerline-theme.tmux` somewhere. 32 | 2. Run in a shell: `sh powerline-theme.tmux` 33 | 34 | ### Manual install in `tmux.conf` 35 | 36 | 1. Save `powerline-theme.tmux` to `$HOME/.tmux/tmux-powerline-theme/powerline-theme.tmux` 37 | 2. Put in your `tmux.conf`: `run-shell "$HOME/.tmux/tmux-powerline-theme/powerline-theme.tmux"` 38 | 39 | ## Configure 40 | 41 | All paths assume installation by Tmux Plugin Manager. 42 | 43 | $HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux 44 | 45 | ### Enable Powerline symbols 46 | 47 | *If you don't want Powerline symbols, simply load the theme.* 48 | 49 | ```tmux 50 | # 51 | # Powerline theme 52 | # 53 | 54 | # Enable Powerline symbols (unless already specified otherwise in environment) 55 | if-shell ': ${TMUX_POWERLINE_SYMBOLS?}' '' 'set-environment -g TMUX_POWERLINE_SYMBOLS "powerline"' 56 | 57 | # Toggle between Powerline and Unicode symbols with ^B P 58 | 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"' 59 | ``` 60 | 61 | ### Symbol alternatives 62 | 63 | | Option | Explanation 64 | | --------------- | ----------- 65 | | `powerline` | Use the new Powerline symbols. (January 2013 or later) 66 | | `vim-powerline` | Use the old Powerline symbols from the now deprecated [Lokaltog/vim-powerline](https://github.com/Lokaltog/vim-powerline) project. 67 | | `unicode` | Use Unicode symbols. *(default)* 68 | | `ascii` | Use ASCII symbols. 69 | | `none` | No symbols. 70 | 71 | *Both `unicode` and `ascii` effectively mean no symbols at this time.* 72 | 73 | ### Compact mode 74 | 75 | Environment variables. Run in shell either before starting Tmux or execute `powerline-theme.tmux` afterward to apply. 76 | 77 | #### Compact current window 78 | 79 | ```sh 80 | export TMUX_POWERLINE_COMPACT_CURRENT=on 81 | ``` 82 | 83 | #### Compact other windows 84 | 85 | ```sh 86 | export TMUX_POWERLINE_COMPACT_OTHER=on 87 | ``` 88 | 89 | ### Flag 90 | 91 | ```sh 92 | export TMUX_POWERLINE_FLAG=on 93 | ``` 94 | 95 | ### Symbols 96 | 97 | ```sh 98 | export TMUX_POWERLINE_SYMBOLS="powerline" 99 | ``` 100 | 101 | ## Suggestions 102 | 103 | ### Toggle key for symbols 104 | 105 | Switch between two sets of symbols with `^B P` by putting this in your `.tmux.conf`. 106 | 107 | ```tmux 108 | # Toggle between Unicode and new Powerline symbols 109 | 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"' 110 | ``` 111 | 112 | ### Enable and disable keys for symbols 113 | 114 | Add these lines to your `.tmux.conf` and replace the brackets with your preferred keys. 115 | 116 | ```tmux 117 | bind-key set-environment -g TMUX_POWERLINE_SYMBOLS "powerline" \; run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux" 118 | bind-key set-environment -g TMUX_POWERLINE_SYMBOLS "unicode" \; run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux" 119 | ``` 120 | 121 | ### Change symbols manually while Tmux is running 122 | 123 | ```sh 124 | tmux set-environment -g TMUX_POWERLINE_SYMBOLS "powerline" 125 | tmux run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux" 126 | ``` 127 | 128 | Or replace `tmux` with pressing `^B :` to use Tmux's command line. 129 | 130 | ### Attach Tmux on device without Powerline font 131 | 132 | Run the following in a shell, then optionally specify its location as command to run on connect in your SSH client. 133 | 134 | ```sh 135 | mkdir -p "$HOME/Executables" 136 | 137 | cat << 'EOF' > "$HOME/Executables/TmuxAttachMobile.sh" 138 | #!/bin/sh 139 | 140 | # Set desired symbols. 141 | tmux set-environment -g TMUX_POWERLINE_SYMBOLS "unicode" 142 | 143 | # Run Powerline theme again to apply. 144 | tmux run-shell "$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux" 145 | 146 | # Attach Tmux. 147 | tmux attach 148 | EOF 149 | 150 | chmod +x "$HOME/Executables/TmuxAttachMobile.sh" 151 | ``` 152 | -------------------------------------------------------------------------------- /demo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Examples 5 | # 6 | # - 256 colors 7 | # - 16 colors 8 | # - 256 colors compact 9 | # - 16 colors compact 10 | # - 256 colors with flag 11 | # - 16 colors with flag 12 | # - 256 colors compact with flag 13 | # - 16 colors compact with flag 14 | # 15 | 16 | # Powerline theme settings. 17 | #export TMUX_POWERLINE_COMPACT_CURRENT="on" 18 | #export TMUX_POWERLINE_COMPACT_OTHER="on" 19 | #export TMUX_POWERLINE_FLAG="on" 20 | 21 | # Path to Powerline theme. 22 | target="$HOME/.tmux/plugins/tmux-powerline-theme/powerline-theme.tmux" 23 | 24 | # Set static information. Restored at end of script. 25 | sessionwindowpane="0:2:1" 26 | hostname="esko.bar" 27 | date="Mar 04 Fri" 28 | time="04:20" 29 | 30 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)#S:#I:#P/\1${sessionwindowpane}/" "$target" 31 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)#H/\1${hostname}/" "$target" 32 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)%b %d %a/\1${date}/" "$target" 33 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)%H:%M/\1${time}/" "$target" 34 | 35 | # Open windows. 36 | tmux new-session -d -s "Demo" -n "Normal" "$SHELL" 37 | tmux set-option -t Demo base-index 1 38 | tmux new-window -t Demo:2 -n "Current" "$EDITOR ; $SHELL" 39 | tmux new-window -t Demo:3 -n "Last" "$SHELL" 40 | tmux new-window -t Demo:4 -n "Activity/Silence" "tmux set-window-option -t Demo:4 monitor-silence 1 && $SHELL" 41 | tmux new-window -t Demo:5 -n "Bell" "sleep 1 && echo  && $SHELL" 42 | tmux new-window -t Demo:6 -n "Content" "tmux set-window-option -t Demo:6 monitor-content 'Content!' && sleep 1 && echo 'Content!' && $SHELL" 43 | #tmux new-window -t Demo -n "~/Projects" 44 | #tmux new-window -t Demo -n "vim .tmux.conf" 45 | #tmux new-window -t Demo -n "CMUS" 46 | #tmux new-window -t Demo -n "top" 47 | #tmux new-window -t Demo -n "WeeChat" "sleep 1 && echo  && $SHELL" 48 | #tmux new-window -t Demo -n "" 49 | #tmux new-window -t Demo -n "" "tmux set-window-option -t Demo:13 monitor-silence 1 && $SHELL" 50 | #tmux new-window -t Demo -n "" 51 | #tmux new-window -t Demo -n "" 52 | 53 | tmux select-window -t Demo:3 54 | tmux select-window -t Demo:2 55 | 56 | # Reload Powerline theme. 57 | source "$target" 58 | 59 | # Restore configuration. 60 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)${sessionwindowpane}/\1#S:#I:#P/" "$target" 61 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)${hostname}/\1#H/" "$target" 62 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)${date}/\1%b %d %a/" "$target" 63 | sed -i.bak "s/^\(tmux set-window-option -g status-right.*\)${time}/\1%H:%M/" "$target" 64 | 65 | # Delete Sed's backup file. 66 | rm "${target}.bak" 67 | 68 | # Show everything. 69 | tmux attach -t Demo 70 | -------------------------------------------------------------------------------- /powerline-theme.tmux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Powerline symbols 5 | # 6 | 7 | : ${TMUX_POWERLINE_SYMBOLS:=unicode} 8 | 9 | case "$TMUX_POWERLINE_SYMBOLS" in 10 | powerline ) 11 | # Powerline glyphs at U+E000-U+F8FF range ("Private Use Area") 12 | # These are the code points used in the new universal Powerline 13 | tmux_powerline_symbol_right_full="" 14 | tmux_powerline_symbol_right_thin="" 15 | tmux_powerline_symbol_left_full="" 16 | tmux_powerline_symbol_left_thin="" 17 | ;; 18 | vim-powerline ) 19 | # Powerline glyphs at U+2B60-U+2BFF range ("Miscellaneous Symbols and Arrows") 20 | # These are the code points used in Lokaltog/vim-powerline 21 | tmux_powerline_symbol_right_full="⮀" 22 | tmux_powerline_symbol_right_thin="⮁" 23 | tmux_powerline_symbol_left_full="⮂" 24 | tmux_powerline_symbol_left_thin="⮃" 25 | ;; 26 | unicode ) 27 | # Unicode glyphs which don't require patched font 28 | tmux_powerline_symbol_right_full="" 29 | tmux_powerline_symbol_right_thin="│" 30 | tmux_powerline_symbol_left_full="" 31 | tmux_powerline_symbol_left_thin="│" 32 | ;; 33 | ascii ) 34 | # ASCII glyphs which don't require patched font or Unicode support 35 | tmux_powerline_symbol_right_full="" 36 | tmux_powerline_symbol_right_thin="|" 37 | tmux_powerline_symbol_left_full="" 38 | tmux_powerline_symbol_left_thin="|" 39 | ;; 40 | none | * ) 41 | # No symbols. 42 | tmux_powerline_symbol_right_full="" 43 | tmux_powerline_symbol_right_thin="" 44 | tmux_powerline_symbol_left_full="" 45 | tmux_powerline_symbol_left_thin="" 46 | esac 47 | 48 | # 49 | # Show flag if terminal reports support for fewer than 8 colors 50 | # 51 | # Current: * 52 | # Previous: - 53 | # Activity/Silence: # 54 | # Bell: ! 55 | # Content: + 56 | # 57 | 58 | enable_flag() 59 | { 60 | tmux_powerline_flag="#F" 61 | } 62 | 63 | disable_flag() 64 | { 65 | tmux_powerline_flag="" 66 | } 67 | 68 | # Support `tput Co` too? 69 | colors="$(tput colors)" 70 | 71 | if [ "${TMUX_POWERLINE_FLAG}" = "on" ]; then 72 | # Force enable flag 73 | enable_flag 74 | elif [ "${TMUX_POWERLINE_FLAG}" = "off" ]; then 75 | # Force disable flag 76 | disable_flag 77 | else 78 | # Dynamically enable flag 79 | if [ "$colors" -lt 8 ]; then 80 | # Fewer than n colors supported 81 | enable_flag 82 | else 83 | disable_flag 84 | fi 85 | fi 86 | 87 | # 88 | # Status bar style 89 | # 90 | 91 | tmux set-window-option -g status-style bg=colour236,fg=white 92 | 93 | # 94 | # Status bar left side 95 | # 96 | 97 | # Show session name? 98 | if [ "${TMUX_POWERLINE_SHOW_SESSION_NAME}" = "on" ]; then 99 | tmux set-window-option -g status-left "#[bg=colour240,fg=white] #S #[fg=colour236,reverse]${tmux_powerline_symbol_right_full}" 100 | tmux set-window-option -g status-left-length 40 101 | else 102 | tmux set-window-option -g status-left "" 103 | #tmux set-window-option -g status-left-length 40 104 | fi 105 | 106 | # 107 | # Status bar right side 108 | # 109 | 110 | tmux set-window-option -g status-right "#[fg=colour244]#S:#I:#P #[fg=colour240]${tmux_powerline_symbol_left_full}#[fg=colour231,bg=colour240] #H #[fg=colour252]${tmux_powerline_symbol_left_full}#[fg=black,bg=colour252,nobold] %b %d %a #[bold]%H:%M " 111 | tmux set-window-option -g status-right-length 80 112 | 113 | # 114 | # Status bar window currently active 115 | # 116 | 117 | if [ "${TMUX_POWERLINE_COMPACT_CURRENT}" = "on" ]; then 118 | tmux set-window-option -g window-status-current-format "#[fg=colour236]${tmux_powerline_symbol_right_full}#[default,fg=colour231,bold] #I${tmux_powerline_flag} #[default,fg=colour236,reverse]${tmux_powerline_symbol_right_full}" 119 | else 120 | tmux set-window-option -g window-status-current-format "#[fg=colour236]${tmux_powerline_symbol_right_full}#[default,bold] #I${tmux_powerline_flag} #[fg=colour123,reverse]${tmux_powerline_symbol_right_full}#[default]#[bg=colour123] #W #[fg=colour236,reverse]${tmux_powerline_symbol_right_full}" 121 | fi 122 | 123 | # colour33 is green 124 | tmux set-window-option -g window-status-current-style none,bg=colour33,fg=black 125 | 126 | # 127 | # Status bar window in background (not active) 128 | # 129 | 130 | if [ "${TMUX_POWERLINE_COMPACT_OTHER}" = "on" ]; then 131 | tmux set-window-option -g window-status-format "#[fg=colour236,nounderscore]${tmux_powerline_symbol_right_full}#[default,bold,nounderscore] #I${tmux_powerline_flag} #[fg=colour236,reverse]${tmux_powerline_symbol_right_full}" 132 | else 133 | tmux set-window-option -g window-status-format "#[fg=colour236,nounderscore]${tmux_powerline_symbol_right_full}#[default,bold,nounderscore] #I${tmux_powerline_flag} #[fg=colour240,reverse]${tmux_powerline_symbol_right_full}#[default]#[bg=colour240]#[nounderscore] #[default]#[fg=colour231,bg=colour240]#W#[nounderscore] #[fg=colour236,reverse]${tmux_powerline_symbol_right_full}" 134 | fi 135 | 136 | # Black on green 137 | tmux set-window-option -g window-status-style none,bg=colour76,fg=black 138 | 139 | # Black on white 140 | #tmux set-window-option -g window-status-style bg=colour231,fg=black 141 | 142 | # Green more alike non-256color 143 | #tmux set-window-option -g window-status-style bg=colour40 144 | 145 | # 146 | # Status bar window last active (Tmux 1.8+) 147 | # 148 | 149 | tmux set-window-option -g window-status-last-style none,bg=cyan,fg=black 150 | 151 | # 152 | # Status bar window with activity/silence (monitor-activity, monitor-silence) 153 | # 154 | 155 | # colour127 is pink 156 | tmux set-window-option -g window-status-activity-style bold,bg=colour127,fg=black 157 | 158 | # 159 | # Status bar window with bell triggered 160 | # 161 | 162 | # red is urgent 163 | tmux set-window-option -g window-status-bell-style bold,bg=red,fg=black 164 | 165 | # 166 | # Status bar window with content found (monitor-content) (Tmux <2.0) 167 | # 168 | 169 | #tmux set-window-option -g window-status-content-attr bold #,underscore 170 | #tmux set-window-option -g window-status-content-bg colour226 # Yellow because search highlighting usually is 171 | #tmux set-window-option -g window-status-content-fg black 172 | --------------------------------------------------------------------------------