parent
4fa17f6ff5
commit
2e5b9383a5
|
@ -12,8 +12,16 @@ _powerline_tmux_set_columns() {
|
|||
_powerline_tmux_setenv COLUMNS "$COLUMNS"
|
||||
}
|
||||
|
||||
trap "_powerline_tmux_set_columns" SIGWINCH
|
||||
kill -SIGWINCH "$$"
|
||||
_powerline_prompt() {
|
||||
[[ -z "$POWERLINE_OLD_PROMPT_COMMAND" ]] ||
|
||||
eval $POWERLINE_OLD_PROMPT_COMMAND
|
||||
PS1="$(powerline shell left -r bash_prompt --last_exit_code=$?)"
|
||||
_powerline_tmux_set_pwd
|
||||
}
|
||||
|
||||
export PROMPT_COMMAND="_powerline_tmux_set_pwd"
|
||||
export PS1='$(powerline shell left --last_exit_code=$?)'
|
||||
trap "_powerline_tmux_set_columns" SIGWINCH
|
||||
_powerline_tmux_set_columns
|
||||
|
||||
[[ "$PROMPT_COMMAND" == "_powerline_prompt" ]] ||
|
||||
POWERLINE_OLD_PROMPT_COMMAND="$PROMPT_COMMAND"
|
||||
export PROMPT_COMMAND="_powerline_prompt"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from powerline.renderers.shell import ShellRenderer
|
||||
|
||||
|
||||
class BashPromptRenderer(ShellRenderer):
|
||||
'''Powerline bash prompt segment renderer.'''
|
||||
def hl(self, contents=None, fg=None, bg=None, attr=None):
|
||||
'''Highlight a segment.
|
||||
|
||||
Returns the default ShellRenderer escape sequence with \[...\] wrapped
|
||||
around it (required in bash prompts).
|
||||
'''
|
||||
return '\[' + super(BashPromptRenderer, self).hl(None, fg, bg, attr) + '\]' + (contents or u'')
|
||||
|
||||
@staticmethod
|
||||
def escape(string):
|
||||
return string.replace('\\', '\\\\').replace('$', '\\$').replace('`', '\\`')
|
Loading…
Reference in New Issue