Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Fix RPROMPT_ON_NEWLINE when PROMPT_ON_NEWLINE is set to false #843

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions powerlevel9k.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -1500,26 +1500,25 @@ powerlevel9k_prepare_prompts() {
# Reset start time
_P9K_TIMER_START=0x7FFFFFFF

if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Reason why that codeblock was inside of POWERLEVEL9K_PROMPT_ON_NEWLINE is that we wanted to align left and right prompt accordingly. So, with your change it is possible to have no newline on the left prompt at all, but move the right prompt one line up..
I don't say that this is necessarily bad, as the user still has full control over this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is an impediment for merging, I can add a check for newlinesegments too.
On other hand, if you have POWERLEVEL9K_PROMPT_ADD_NEWLINE=true and the right prompt is printed one line before the left prompt, you can think of the segments in the right prompt as related to the previous command, like the status segment. I think this would provide another nice option for the right prompt.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I wanted!

# The right prompt should be on the same line as the first line of the left
# prompt. To do so, there is just a quite ugly workaround: Before zsh draws
# the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we
# advise it to go one line down. See:
# http://superuser.com/questions/357107/zsh-right-justify-in-ps1
local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters
RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up
RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down
else
RPROMPT_PREFIX=''
RPROMPT_SUFFIX=''
fi

if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then
PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt)
$(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')'
if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then
# The right prompt should be on the same line as the first line of the left
# prompt. To do so, there is just a quite ugly workaround: Before zsh draws
# the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we
# advise it to go one line down. See:
# http://superuser.com/questions/357107/zsh-right-justify-in-ps1
local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters
RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up
RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down
else
RPROMPT_PREFIX=''
RPROMPT_SUFFIX=''
fi
else
PROMPT='%f%b%k$(build_left_prompt)'
RPROMPT_PREFIX=''
RPROMPT_SUFFIX=''
fi

if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then
Expand Down