Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 949 forks source link

Cursor and right prompt misplaced #1327

Closed KumarNarendra closed 5 years ago

KumarNarendra commented 5 years ago

Describe Your Issue

The cursor is misplaced to left and behave weirdly on typing. Also, the right prompt display seems to be malfunctioning as the segments are shifted to left and there is blank space on the right of the prompt.

image

Have you tried to debug or fix it?

Nope. Not sure how to do that.

Environment Information

This information will help us understand your configuration.

KumarNarendra commented 5 years ago

image

romkatv commented 5 years ago

Please post your ~/.zshrc.

KumarNarendra commented 5 years ago

Powerlevel9k settings

POWERLEVEL9K_MODE="nerdfont-complete" POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true

POWERLEVEL9K_SHORTEN_DIR_LENGTH=2

POWERLEVEL9K_SHORTEN_DELIMITER=".."

POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last"

POWERLEVEL9K_DIR_SHOW_WRITABLE=true POWERLEVEL9K_PROMPT_ON_NEWLINE=true POWERLEVEL9K_PROMPT_ADD_NEWLINE=true POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon user root_indicator context dir dir_writable virtualenv anaconda pyenv vcs) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs history time java_version node_version) POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S | %d.%m.%y}"

POWERLEVEL9K_VCS_SHORTEN_LENGTH=25

POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=11

POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"

POWERLEVEL9K_VCS_SHORTEN_DELIMITER=".."

POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='red'

Add a space in the first prompt

POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%f"

Visual customisation of the second prompt line

local user_symbol="$" if [[ $(print -P "%#") =~ "#" ]]; then user_symbol = "#" fi

POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%{%B%F{black}%K{yellow}%} $user_symbol%{%b%f%k%F{yellow}%} %{%f%}"

Set default user to avoid showing 'user' on every line

DEFAULT_USER=$USER ZSH_THEME="powerlevel9k/powerlevel9k"

romkatv commented 5 years ago

Is this really the whole content of your ~/.zshrc? My guess is that it's something else you have there that breaks your prompt. If you disable all plugins and other customizations and leave just the theme and POWERLEVEL9K options, does it fix your prompt?

KumarNarendra commented 5 years ago

By removing everything and just using the default configurations also didn't work. But When I switched to

powerlevel10K

it seems to work fine, with one exception: left_prompt_segment:87: bad math expression: illegal character: ^/ This occurs for the VCS segment when the branch has subfolders strategy.

romkatv commented 5 years ago

This occurs for the VCS segment when the branch has subfolders strategy.

Could you post the full config that triggers this problem?

KumarNarendra commented 5 years ago

Here is the full config:

` export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8

If you come from bash you might have to change your $PATH.

export PATH=$HOME/bin:/usr/local/bin:$PATH

export TERM="xterm-256color"

Path to your oh-my-zsh installation.

export ZSH="/Users/narendrakumar/.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="robbyrussell"

Powerlevel9k settings

POWERLEVEL9K_MODE="nerdfont-complete" POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='cyan' POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true

POWERLEVEL9K_SHORTEN_DIR_LENGTH=2

POWERLEVEL9K_SHORTEN_DELIMITER=".."

POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last"

POWERLEVEL9K_DIR_SHOW_WRITABLE=true POWERLEVEL9K_PROMPT_ON_NEWLINE=true POWERLEVEL9K_PROMPT_ADD_NEWLINE=true POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon user root_indicator context dir dir_writable vcs) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs history time java_version node_version) POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S | %d.%m.%y}"

POWERLEVEL9K_VCS_SHORTEN_LENGTH=25

POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=11

POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"

POWERLEVEL9K_VCS_SHORTEN_DELIMITER=".."

POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='red'

Add a space in the first prompt

POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%f"

Visual customisation of the second prompt line

local user_symbol="$" if [[ $(print -P "%#") =~ "#" ]]; then user_symbol = "#" fi

POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%{%B%F{black}%K{yellow}%} $user_symbol%{%b%f%k%F{yellow}%} %{%f%}"

Set default user to avoid showing 'user' on every line

DEFAULT_USER=$USER

ZSH_THEME="powerlevel9k/powerlevel9k"

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 change how often to auto-update (in days).

export UPDATE_ZSH_DAYS=13

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=( archlinux autojump aws battery bgnotify boot2docker bower branch brew bwana cf cloudfoundry colored-man-pages colorize command-not-found copybuffer copydir copyfile cp dircycle dirhistory django docker docker-compose docker-machine droplr emoji emoji-clock encode64 extract fd gb git git-auto-fetch git-extras git-prompt gitignore go golang gradle grails grunt gulp helm heroku httpie iterm2 jenv jira jsontools jump kops kube-ps1 kubectl man minikube mvn ng node npm nvm osx per-directory-history perms postgres pylint python rsync sbt scala sdk spring sublime sudo swiftpm systemadmin systemd terraform themes timer tmux tmuxinator urltools virtualenv vscode wd web-search xcode yarn zsh-autosuggestions zsh-navigation-tools zsh_reload zsh-syntax-highlighting )

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

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"

ssh

export SSH_KEY_PATH="~/.ssh/rsa_id"

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"

export PATH="/usr/local/opt/sqlite/bin:$PATH"

source /usr/local/share/antigen/antigen.zsh

Bring in external plugins using Antigen

antigen bundle djui/alias-tips

Apply antigen transformations

All other antigen calls should be preceded by the "antigen apply" call

antigen apply

TIMER_FORMAT='[%d]'; TIMER_PRECISION=2;

setting for making command BOLD

BOLD="[\033[1m]"

OFF="[\033[m]"

PS1="${OFF}\u@\h:\w \$${BOLD}"

`

romkatv commented 5 years ago

I took your config as the base, removed plugins that don't exist in the standard Oh-My-Zsh installation, removed plugins that complain on startup that I don't have the required software installed, and eventually got it working. I couldn't reproduce the problem.

This occurs for the VCS segment when the branch has subfolders strategy.

Could you clarify what "the branch has subfolders strategy" means? What do I need to do to trigger the problem?

P.S.

The original problem was caused by timer plugin. You need to disable it as it's incompatible with many themes including Powerlevel10k. The good thing is that you have command_execution_time in your Powerlevel10k config, so you don't need the functionality provided by the timer plugin.

You also have several plugins that do literally nothing except make your prompt slow. You need to remove them. I identified these two: git-prompt, kube-ps1.

Another source of slowness is bgnotify plugin. Unless you really want it, I'd recommend removing it.

After removing these plugins I've got reasonable prompt latency although it's still a bit sluggish. The number of plugins you have is quite incredible, so it's not surprising to be crippling to the performance of ZSH.

KumarNarendra commented 5 years ago

Could you clarify what "the branch has subfolders strategy" means? What do I need to do to trigger the problem?

To reproduce the issue your branch should have a name with /, something like this:

abc/kumarn/replace-the-calculated-fields

KumarNarendra commented 5 years ago

Looks like the issue got resolved. Not sure how. But removing all the suggested plugins seems to fix the issue.

romkatv commented 5 years ago

Phew, I'm glad. I wasn't able to reproduce the issue by creating branch abc/kumarn/replace-the-calculated-fields, so I started writing a fairly complex command that would help diagnose the problem on your side. It's a relief that it's no longer necessary.

By the way, the number of plugins you have enabled is really high. It's an order of magnitude more than I normally see. Most plugins in oh-my-zsh are useless to 99% of ZSH users, a fair number are harmful. It's a good idea to enable only the plugins that you actually need. If you aren't sure what a given plugin does, don't enable it. When in doubt, don't enable.

romkatv commented 5 years ago

@KumarNarendra

There is another user reporting the same "bad math expression" error on the same line: https://github.com/romkatv/powerlevel10k/issues/110. Unfortunately, they also cannot reproduce this after filing the issue. I added that chunk of code just yesterday. Two users seeing the same error message on the same line of code added just a day ago is almost a certain sign of a bug. If you see this error again, please try to figure out which properties of your environment lead to it. I'd very much like to reproduce it so that I can fix it.

dritter commented 5 years ago

Glad you got it working @KumarNarendra . Thanks @romkatv for trying to fix it.

romkatv commented 5 years ago

For the record, I've fixed that "bad math expression" bug when @mmariani figured out how to reproduce it and helped me to replicate the setup on my machine.

KumarNarendra commented 5 years ago

For the record, I've fixed that "bad math expression" bug when @mmariani figured out how to reproduce it and helped me to replicate the setup on my machine.

@romkatv Great news. Thanks for letting us know.