Make PS2 display something more meaningful: add continuation segment
This commit is contained in:
parent
aff028e4e9
commit
772a09d01b
|
@ -115,10 +115,11 @@ _powerline_setup_prompt() {
|
||||||
local add_args='--last_exit_code=$? --last_pipe_status="$pipestatus"'
|
local add_args='--last_exit_code=$? --last_pipe_status="$pipestatus"'
|
||||||
add_args+=' --renderer_arg="client_id=$$"'
|
add_args+=' --renderer_arg="client_id=$$"'
|
||||||
add_args+=' --jobnum=$_POWERLINE_JOBNUM'
|
add_args+=' --jobnum=$_POWERLINE_JOBNUM'
|
||||||
|
local add_args_2=$add_args' -R parser_state=${(%%):-%_} -R local_theme=continuation'
|
||||||
PS1='$($POWERLINE_COMMAND shell left -r zsh_prompt '$add_args')'
|
PS1='$($POWERLINE_COMMAND shell left -r zsh_prompt '$add_args')'
|
||||||
RPS1='$($POWERLINE_COMMAND shell right -r zsh_prompt '$add_args')'
|
RPS1='$($POWERLINE_COMMAND shell right -r zsh_prompt '$add_args')'
|
||||||
PS2='$($POWERLINE_COMMAND shell left -r zsh_prompt -R local_theme=continuation '$add_args')'
|
PS2='$($POWERLINE_COMMAND shell left -r zsh_prompt '$add_args_2')'
|
||||||
RPS2='$($POWERLINE_COMMAND shell right -r zsh_prompt -R local_theme=continuation '$add_args')'
|
RPS2='$($POWERLINE_COMMAND shell right -r zsh_prompt '$add_args_2')'
|
||||||
PS3='$($POWERLINE_COMMAND shell left -r zsh_prompt -R local_theme=select '$add_args')'
|
PS3='$($POWERLINE_COMMAND shell left -r zsh_prompt -R local_theme=select '$add_args')'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
"branch": { "fg": "gray9", "bg": "gray2" },
|
"branch": { "fg": "gray9", "bg": "gray2" },
|
||||||
"branch_dirty": { "fg": "brightyellow", "bg": "gray2" },
|
"branch_dirty": { "fg": "brightyellow", "bg": "gray2" },
|
||||||
"branch_clean": { "fg": "gray9", "bg": "gray2" },
|
"branch_clean": { "fg": "gray9", "bg": "gray2" },
|
||||||
"prompt": { "fg": "gray9", "bg": "gray4" },
|
"continuation": { "fg": "gray9", "bg": "gray4" },
|
||||||
|
"continuation:current": { "fg": "gray10", "bg": "gray4", "attr": ["bold"] },
|
||||||
"cwd": { "fg": "gray9", "bg": "gray4" },
|
"cwd": { "fg": "gray9", "bg": "gray4" },
|
||||||
"cwd:current_folder": { "fg": "gray10", "bg": "gray4", "attr": ["bold"] },
|
"cwd:current_folder": { "fg": "gray10", "bg": "gray4", "attr": ["bold"] },
|
||||||
"cwd:divider": { "fg": "gray7", "bg": "gray4" },
|
"cwd:divider": { "fg": "gray7", "bg": "gray4" },
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
{
|
{
|
||||||
|
"default_module": "powerline.segments.shell",
|
||||||
"segments": {
|
"segments": {
|
||||||
"left": [
|
"left": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"name": "continuation"
|
||||||
"contents": "",
|
|
||||||
"width": "auto",
|
|
||||||
"align": "r",
|
|
||||||
"highlight_group": ["prompt"]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"right": [
|
"right": [
|
||||||
|
|
|
@ -72,3 +72,48 @@ def mode(pl, segment_info, override={'vicmd': 'COMMND', 'viins': 'INSERT'}, defa
|
||||||
# code or by somebody knowing what he is doing there is absolutely no
|
# code or by somebody knowing what he is doing there is absolutely no
|
||||||
# need in keeping translations dictionary.
|
# need in keeping translations dictionary.
|
||||||
return mode.upper()
|
return mode.upper()
|
||||||
|
|
||||||
|
|
||||||
|
@requires_segment_info
|
||||||
|
def continuation(pl, segment_info, omit_cmdsubst=True, right_align=False, renames={}):
|
||||||
|
'''Display parser state.
|
||||||
|
|
||||||
|
:param bool omit_cmdsubst:
|
||||||
|
Do not display cmdsubst parser state if it is the last, but not the only
|
||||||
|
one.
|
||||||
|
:param bool right_align:
|
||||||
|
Align to the right.
|
||||||
|
:param dict renames:
|
||||||
|
Rename states: ``{old_name : new_name}``. If ``new_name`` is ``None``
|
||||||
|
then given state is not displayed.
|
||||||
|
|
||||||
|
Highlight groups used: ``continuation``, ``continuation:current``.
|
||||||
|
'''
|
||||||
|
if not segment_info['parser_state']:
|
||||||
|
return None
|
||||||
|
ret = []
|
||||||
|
|
||||||
|
for state in segment_info['parser_state'].split():
|
||||||
|
state = renames.get(state, state)
|
||||||
|
if state:
|
||||||
|
ret.append({
|
||||||
|
'contents': state,
|
||||||
|
'highlight_group': 'continuation',
|
||||||
|
'draw_inner_divider': True,
|
||||||
|
})
|
||||||
|
|
||||||
|
if omit_cmdsubst and len(ret) > 1 and ret[-1]['contents'] == 'cmdsubst':
|
||||||
|
ret.pop(-1)
|
||||||
|
|
||||||
|
if not ret:
|
||||||
|
ret.append({
|
||||||
|
'contents': ''
|
||||||
|
})
|
||||||
|
|
||||||
|
if right_align:
|
||||||
|
ret[0].update(width='auto', align='r')
|
||||||
|
ret[-1]['highlight_group'] = 'continuation:current'
|
||||||
|
else:
|
||||||
|
ret[-1].update(width='auto', align='l', highlight_group='continuation:current')
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue