Powerlevel9k: Way to add segments on second prompt line?

Created on 23 May 2016  路  7Comments  路  Source: Powerlevel9k/powerlevel9k

I have this config currently

ZSH_THEME="powerlevel9k/powerlevel9k"

POWERLEVEL9K_MODE='awesome-patched'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status node_version)

POWERLEVEL9K_OS_ICON_BACKGROUND="white"
POWERLEVEL9K_OS_ICON_FOREGROUND="blue"
POWERLEVEL9K_DIR_HOME_FOREGROUND="white"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="white"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"

Looking like this

screenshot from 2016-05-23 14-00-37
_(link to wiki configs :P tunnckoCore configuration)_

But I'm thinking to reorder the things a bit. And have idea to have second line. So, first line will contain dir and vcs in left, and node_version in right. Second line will be os_icon in left and status in right.

But how can accomplish that? *_PROMPT_ON_NEWLINE and *_MULTILINE_* not helps, because it accepts only strings. How to add segments for second line?

Most helpful comment

@tunnckoCore Unfortunately, for the right prompt we don't have such a mechanism.

Longer explanation:
ZSH offers ways to display informations on left or right side by setting PROMPT (left) and RPROMPT (right). Powerlevel9k fills these variables, and provides an easy way for configuration. So we need to know on which side the current segment should be rendered, that is the left or right parameter of the prompt function (like in: prompt_os_icon left 1).
My earlier suggestion uses one of these configuration points: POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX, which was intended to change the prefix of the second line. Btw. the second line comes from adding a newline in PROMPT, not from a ZSH feature.

Long story short:
We could add new arrays for defining "left/right second line" prompt segments. Then everybody could add segments on first or second line like they want to.

All 7 comments

You could add a custom command that renders as a newline in the left prompt

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs node_version custom_newline os_icon status)
POWERLEVEL9K_CUSTOM_NEWLINE="print '\n '"

Hm. Will try and report back, thanks! :)

I found another way than @V1rgul :
The segments just generate code for ZSH to interpret. So, you need to call the segments as the internal powerlevel9k code would do (name of segment, position, index in array).

This should work:

# Source the theme first!
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX="$(prompt_os_icon left 1 && prompt_battery left 2 && left_prompt_end)"

@dritter yea, that's good, but can't set right side of second line?

tried

POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX="$(prompt_os_icon left 1 && left_prompt_end && prompt_status right 1 && right_prompt_end)"

@tunnckoCore Unfortunately, for the right prompt we don't have such a mechanism.

Longer explanation:
ZSH offers ways to display informations on left or right side by setting PROMPT (left) and RPROMPT (right). Powerlevel9k fills these variables, and provides an easy way for configuration. So we need to know on which side the current segment should be rendered, that is the left or right parameter of the prompt function (like in: prompt_os_icon left 1).
My earlier suggestion uses one of these configuration points: POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX, which was intended to change the prefix of the second line. Btw. the second line comes from adding a newline in PROMPT, not from a ZSH feature.

Long story short:
We could add new arrays for defining "left/right second line" prompt segments. Then everybody could add segments on first or second line like they want to.

Marking this one closed. Thanks for the great support, @dritter and @V1rgul!

i can not add segment the way @dritter show, it doesn't works for me.
@dritter had a good idea, actually how this great idea has been implemented and how to use it please ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mingrammer picture mingrammer  路  4Comments

davidmpaz picture davidmpaz  路  3Comments

dritter picture dritter  路  5Comments

guidoilbaldo picture guidoilbaldo  路  5Comments

jpdoria picture jpdoria  路  5Comments