Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Padding on the right prompt #87

Closed
MycroftHolmes1989 opened this issue Jun 12, 2019 · 16 comments
Closed

Padding on the right prompt #87

MycroftHolmes1989 opened this issue Jun 12, 2019 · 16 comments

Comments

@MycroftHolmes1989
Copy link

I am using the my powerlevel9k config with powerlevel10k on Ubuntu. On Terminator as well as GNOME Terminal Emulator, there is some padding on right side of the right prompt. The issue is demonstrated on this screenshot. My config for the right prompt is:
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs history)

@romkatv
Copy link
Owner

romkatv commented Jun 12, 2019

Try the following experiment. Type this command:

PROMPT='X> ' RPROMPT='<X' zsh -df

Note that there is space after <X on the right. Now type this:

ZLE_RPROMPT_INDENT=0

The space is gone. You can also try ZLE_RPROMPT_INDENT=2.

From http://zsh.sourceforge.net/Doc/Release/Parameters.html:

ZLE_RPROMPT_INDENT <S>

If set, used to give the indentation between the right hand side of the right prompt in the line editor as given by RPS1 or RPROMPT and the right hand side of the screen. If not set, the value 1 is used.

What you see with p10k is the expected behavior. p9k has a bug: Powerlevel9k/powerlevel9k#1292.

If you don't want to have right prompt indented, set ZLE_RPROMPT_INDENT=0. Note that it may trigger a bug in ZSH on some terminals. This bug will cause the cursor to be positioned incorrectly. I've fixed the bug in zsh-users/zsh@3eea35d but there hasn't been a ZSH release since then. If you really want to get rid of the space and you must use a terminal on which the bug triggers, you'll need to build ZSH yourself.

@MycroftHolmes1989
Copy link
Author

Thank you for the explanation. Setting ZLE_RPROMPT_INDENT=0 does solve it, and Terminator does not seem to trigger the bug.

@romkatv
Copy link
Owner

romkatv commented Jun 12, 2019

Terminator does not seem to trigger the bug.

I hope this is true although this doesn't match my recollection.

To ensure the bug is indeed not triggered you can conduct these tests.

  1. When you prompt is empty, verify that the cursor is where it's supposed to be. If there is no space between the end of left prompt and the cursor, you are affected by the bug.
  2. Press ctrl+r. The cursor must not move. If it does move to the right, you are affected by the bug.
  3. Type ls<tab>. You should have ls on the screen with the cursor positioned right after it. If the cursor is positioned on s, you are affected by the bug.

@MycroftHolmes1989
Copy link
Author

MycroftHolmes1989 commented Jun 12, 2019

Okay. I stand corrected. Both Terminator and GNOME Terminal are affected by it.

@romkatv
Copy link
Owner

romkatv commented Jun 14, 2019

@MycroftHolmes1989 I've implemented a workaround in Powerlevel10k for the ZSH bug.

If you update powerlevel10k, your cursor should behave correctly even if you set ZLE_RPROMPT_INDENT=0. Please let me know whether it works for you.

@MycroftHolmes1989
Copy link
Author

Unfortunately, it doesn't work on Terminator or GNOME Terminal, even after the update.

@romkatv
Copy link
Owner

romkatv commented Jun 14, 2019

This is surprising, as I've tested my workaround on these terminals. Please type zsh -df and then paste the following:

rm -rf /tmp/p10k
git clone https://github.com/romkatv/powerlevel10k.git /tmp/p10k
ZLE_RPROMPT_INDENT=0
source /tmp/p10k/powerlevel10k.zsh-theme

If this works, the most likely explanation is that your powerlevel10k version is not up to date.

@MycroftHolmes1989
Copy link
Author

MycroftHolmes1989 commented Jun 14, 2019

It works when I do it from /tmp. But I have deleted $ZSH_CUSTOM/themes/powerlevel10k, and then installed it again, but it's still not working on GNOME Terminal or Terminator.

@romkatv
Copy link
Owner

romkatv commented Jun 14, 2019

Please post a screenshot of your prompt (when it's in the non-working state) and your ~/.zshrc.

@romkatv
Copy link
Owner

romkatv commented Jun 14, 2019

You can drag-and-drop images to the comment edit box on GitHub.

@MycroftHolmes1989
Copy link
Author

MycroftHolmes1989 commented Jun 14, 2019

Screenshots:
Screenshot from 2019-06-15 01-26-43
Screenshot from 2019-06-15 01-27-14

.zshrc:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/home/nemo/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
 COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git
	 virtualenv
	 ubuntu
	 emotty
	 tmux)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

source ~/.zsh_aliases
source ~/.zsh_functions
source ~/.pl10ksettings

.pl10ksettings:


POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(time root_indicator context dir dir_writable nodeenv virtualenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs history)


POWERLEVEL9K_SHORTEN_STRATEGY="truncate_middle"
POWERLEVEL9K_SHORTEN_DIR_LENGTH=6
POWERLEVEL9KGT_TERMINAL_BACKGROUND='grey'

POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND=$POWERLEVEL9KGT_TERMINAL_BACKGROUND
POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND=$POWERLEVEL9KGT_TERMINAL_BACKGROUND
POWERLEVEL9K_CONTEXT_SUDO_BACKGROUND=$POWERLEVEL9KGT_TERMINAL_BACKGROUND
POWERLEVEL9K_CONTEXT_REMOTE_BACKGROUND=$POWERLEVEL9KGT_TERMINAL_BACKGROUND
POWERLEVEL9K_CONTEXT_REMOTE_SUDO_BACKGROUND=$POWERLEVEL9KGT_TERMINAL_BACKGROUND

POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='cyan'
POWERLEVEL9K_TIME_BACKGROUND='indianred'

@romkatv
Copy link
Owner

romkatv commented Jun 14, 2019

You need to put ZLE_RPROMPT_INDENT=0 in your ~/.zshrc. This will enable the special workaround I implemented in p10k. When you are typing ZLE_RPROMPT_INDENT=0 in your terminal, you are getting the native ZSH experience, which has a bug in your version of ZSH.

@MycroftHolmes1989
Copy link
Author

Resolved! Thanks.

@romkatv
Copy link
Owner

romkatv commented Jun 14, 2019

Phew! That was a tough one. Thanks for verifying.

@enkeyz
Copy link

enkeyz commented Sep 30, 2023

Every time I do a fresh install of a linux distro and install powerlevel10k, this "bug" is always comes up. I'm here for the 20th time :P

@romkatv
Copy link
Owner

romkatv commented Sep 30, 2023

@enkeyz It's a good idea to keep your .zshrc and other rc files in a git repository from which you can recover them when reinstalling the OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants