mirror of
https://github.com/powerline/powerline.git
synced 2025-09-25 19:09:10 +02:00
parent
4fa17f6ff5
commit
2e5b9383a5
@ -12,8 +12,16 @@ _powerline_tmux_set_columns() {
|
|||||||
_powerline_tmux_setenv COLUMNS "$COLUMNS"
|
_powerline_tmux_setenv COLUMNS "$COLUMNS"
|
||||||
}
|
}
|
||||||
|
|
||||||
trap "_powerline_tmux_set_columns" SIGWINCH
|
_powerline_prompt() {
|
||||||
kill -SIGWINCH "$$"
|
[[ -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"
|
trap "_powerline_tmux_set_columns" SIGWINCH
|
||||||
export PS1='$(powerline shell left --last_exit_code=$?)'
|
_powerline_tmux_set_columns
|
||||||
|
|
||||||
|
[[ "$PROMPT_COMMAND" == "_powerline_prompt" ]] ||
|
||||||
|
POWERLINE_OLD_PROMPT_COMMAND="$PROMPT_COMMAND"
|
||||||
|
export PROMPT_COMMAND="_powerline_prompt"
|
||||||
|
18
powerline/renderers/bash_prompt.py
Normal file
18
powerline/renderers/bash_prompt.py
Normal file
@ -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…
x
Reference in New Issue
Block a user