Automatically truncate tmux status line when needed
Closes #1328 (but not fixes it) Closes #137 (not actually fixes it because I do not know some segment widths)
This commit is contained in:
parent
524fc317ad
commit
fe3b3b1598
|
@ -2,11 +2,11 @@ set -g status on
|
|||
set -g status-utf8 on
|
||||
set -g status-interval 2
|
||||
set -g status-left-length 20
|
||||
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=`tmux display -p "#D"`)'
|
||||
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=`tmux display -p "#D"` --width=`tmux display -p "#{client_width}"` -R width_adjust=`tmux show-options -g status-left-length | cut -d" " -f 2`)'
|
||||
set -g status-right-length 150
|
||||
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"
|
||||
set -g window-status-current-format "#[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#[$_POWERLINE_WINDOW_CURRENT_COLOR]#I $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER"
|
||||
|
||||
# Legacy status-left definition to be overwritten for tmux Versions 1.8+
|
||||
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left)"
|
||||
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left --width=`tmux display -p '#{client_width}'` -R width_adjust=`tmux show-options -g status-right-length | cut -d' ' -f2` -R pane_id=`tmux display -p '#D'`)"
|
||||
# vim: ft=tmux
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# powerline_tmux_1.8_plus.conf
|
||||
# tmux Version 1.8 introduces the 'client_prefix' format variable, applicable
|
||||
# for versions 1.8+
|
||||
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env \$POWERLINE_COMMAND \$POWERLINE_COMMAND_ARGS tmux left)"
|
||||
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env \$POWERLINE_COMMAND \$POWERLINE_COMMAND_ARGS tmux left --width=`tmux display -p '#{client_width}'` -R width_adjust=`tmux show-options -g status-right-length | cut -d' ' -f2` -R pane_id=`tmux display -p '#D'`)"
|
||||
# vim: ft=tmux
|
||||
|
|
|
@ -31,6 +31,13 @@ class TmuxRenderer(Renderer):
|
|||
character_translations = Renderer.character_translations.copy()
|
||||
character_translations[ord('#')] = '##[]'
|
||||
|
||||
def render(self, width=None, segment_info={}, **kwargs):
|
||||
if width and segment_info:
|
||||
width -= segment_info.get('width_adjust', 0)
|
||||
if width < 10:
|
||||
width = 10
|
||||
return super(TmuxRenderer, self).render(width=width, segment_info=segment_info, **kwargs)
|
||||
|
||||
def hlstyle(self, fg=None, bg=None, attrs=None):
|
||||
'''Highlight a segment.'''
|
||||
# We don’t need to explicitly reset attributes, so skip those calls
|
||||
|
|
|
@ -11,6 +11,7 @@ mkdir tests/vterm/path
|
|||
ln -s "$(which "${PYTHON}")" tests/vterm/path/python
|
||||
ln -s "$(which bash)" tests/vterm/path
|
||||
ln -s "$(which env)" tests/vterm/path
|
||||
ln -s "$(which cut)" tests/vterm/path
|
||||
ln -s "$PWD/scripts/powerline-render" tests/vterm/path
|
||||
ln -s "$PWD/scripts/powerline-config" tests/vterm/path
|
||||
|
||||
|
|
Loading…
Reference in New Issue