Fix pipestatus segment in case of zsh+zpython
This commit is contained in:
parent
641b0e08a1
commit
62601ad641
|
@ -21,17 +21,10 @@ def get_var_config(var):
|
||||||
|
|
||||||
|
|
||||||
class Args(object):
|
class Args(object):
|
||||||
|
__slots__ = ('last_pipe_status', 'last_exit_code')
|
||||||
ext = ['shell']
|
ext = ['shell']
|
||||||
renderer_module = 'zsh_prompt'
|
renderer_module = 'zsh_prompt'
|
||||||
|
|
||||||
@property
|
|
||||||
def last_exit_code(self):
|
|
||||||
return zsh.last_exit_code()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def last_pipe_status(self):
|
|
||||||
return zsh.pipestatus()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def config(self):
|
def config(self):
|
||||||
try:
|
try:
|
||||||
|
@ -92,6 +85,13 @@ class Environment(object):
|
||||||
environ = Environment()
|
environ = Environment()
|
||||||
|
|
||||||
|
|
||||||
|
class ZshPowerline(ShellPowerline):
|
||||||
|
def precmd(self):
|
||||||
|
self.args.last_pipe_status = zsh.pipestatus()
|
||||||
|
self.args.last_exit_code = zsh.last_exit_code()
|
||||||
|
zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
|
||||||
|
|
||||||
|
|
||||||
class Prompt(object):
|
class Prompt(object):
|
||||||
__slots__ = ('powerline', 'side', 'savedpsvar', 'savedps', 'args', 'theme')
|
__slots__ = ('powerline', 'side', 'savedpsvar', 'savedps', 'args', 'theme')
|
||||||
|
|
||||||
|
@ -104,7 +104,6 @@ class Prompt(object):
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
|
|
||||||
segment_info = {
|
segment_info = {
|
||||||
'args': self.args,
|
'args': self.args,
|
||||||
'environ': environ,
|
'environ': environ,
|
||||||
|
@ -144,7 +143,7 @@ def set_prompt(powerline, psvar, side, theme):
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
powerline = ShellPowerline(Args())
|
powerline = ZshPowerline(Args())
|
||||||
used_powerlines.append(powerline)
|
used_powerlines.append(powerline)
|
||||||
used_powerlines.append(powerline)
|
used_powerlines.append(powerline)
|
||||||
set_prompt(powerline, 'PS1', 'left', None)
|
set_prompt(powerline, 'PS1', 'left', None)
|
||||||
|
@ -153,3 +152,4 @@ def setup():
|
||||||
set_prompt(powerline, 'RPS2', 'right', 'continuation')
|
set_prompt(powerline, 'RPS2', 'right', 'continuation')
|
||||||
set_prompt(powerline, 'PS3', 'left', 'select')
|
set_prompt(powerline, 'PS3', 'left', 'select')
|
||||||
atexit.register(shutdown)
|
atexit.register(shutdown)
|
||||||
|
return powerline
|
||||||
|
|
|
@ -99,6 +99,10 @@ _powerline_set_jobnum() {
|
||||||
_POWERLINE_JOBNUM=${(%):-%j}
|
_POWERLINE_JOBNUM=${(%):-%j}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_powerline_update_counter() {
|
||||||
|
zpython '_powerline.precmd()'
|
||||||
|
}
|
||||||
|
|
||||||
_powerline_setup_prompt() {
|
_powerline_setup_prompt() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
for f in "${precmd_functions[@]}"; do
|
for f in "${precmd_functions[@]}"; do
|
||||||
|
@ -108,8 +112,9 @@ _powerline_setup_prompt() {
|
||||||
done
|
done
|
||||||
precmd_functions+=( _powerline_set_jobnum )
|
precmd_functions+=( _powerline_set_jobnum )
|
||||||
if zmodload libzpython &>/dev/null || zmodload zsh/zpython &>/dev/null ; then
|
if zmodload libzpython &>/dev/null || zmodload zsh/zpython &>/dev/null ; then
|
||||||
|
precmd_functions+=( _powerline_update_counter )
|
||||||
zpython 'from powerline.bindings.zsh import setup as _powerline_setup'
|
zpython 'from powerline.bindings.zsh import setup as _powerline_setup'
|
||||||
zpython '_powerline_setup()'
|
zpython '_powerline = _powerline_setup()'
|
||||||
zpython 'del _powerline_setup'
|
zpython 'del _powerline_setup'
|
||||||
else
|
else
|
||||||
local add_args='--last_exit_code=$? --last_pipe_status="$pipestatus"'
|
local add_args='--last_exit_code=$? --last_pipe_status="$pipestatus"'
|
||||||
|
|
Loading…
Reference in New Issue