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

Changes in my .zshrc file and theme don't change the terminal look. #1339

Open
dbarrett24 opened this issue Jul 16, 2019 · 7 comments
Open

Comments

@dbarrett24
Copy link

dbarrett24 commented Jul 16, 2019

I'm trying to use another person's theme I saw on the Show off Your Config page. When I copy and paste their theme customizations into my .zshrc file and reload the terminal I don't see the changes. Also my default terminal has always looked a bit off:
Screenshot: https://i.imgur.com/h6s1EgJ.png

The background of some of the segments doesn't show up at all.

I'm using the new Windows Terminal and WSL (Windows Subsystem for Linux). My fonts are installed on Windows, not linux.

Most issues are best explained with a screenshot. Please share one if you can!

I've tried making sure the fonts are being targeted in the .zshrc, using Nerd Fonts, etc.

This information will help us understand your configuration.

-version ZSH: 5.1.1
-Oh-My-ZSH

  • What version of P9k are you using? Latest as well as P10k (which supposedly runs faster)

  • Which terminal emulator do you use? the new Windows Terminal

  • Which font do you use? Hack Nerd Font

  • Which font configuration mode are you using? You can check this with (echo $POWERLEVEL9K_MODE).
    nerdfont-complete

  • If this is an icon problem, does the output of $ get_icon_names look correct?

I feel it may be a font issue, but this being the first time I'm using this and being somewhat unfamiliar with many of the shell scripts I'm unsure, which is why i wanted to just copy/paste another person's theme code in hopes it would just work.

MY .zshrc file
`# 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="/root/.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"
POWERLEVEL9k_MODE='nerdfont-complete'

# DAVE'S CUSTOMIZATIONS - THEMING

# Prompt settings
POWERLEVEL9k_PROMPT_ON_NEWLINE=true
POWERLEVEL9k_RPROMPT_ON_NEWLINE=true
POWERLEVEL9k_MULTILINE_FIRST_PROMPT_PREFIX_ICON=$'%K{white}%k'
POWERLEVEL9k_MULTILINE_LAST_PROMPT_PREFIX_ICON=$'%K{green}%F{black} \uf155 %f%F{green}%k\ue0b0%f '

# Separators
POWERLEVEL9k_LEFT_SEGMENT_SEPARATOR_ICON=$'\ue0b0'
POWERLEVEL9k_LEFT_SUBSEGMENT_SEPARATOR_ICON=$'\ue0b1'
POWERLEVEL9k_RIGHT_SEGMENT_SEPARATOR_ICON=$'\ue0b2'
POWERLEVEL9k_RIGHT_SUBSEGMENT_SEPARATOR_ICON=$'\ue0b7'

# Dir colours
POWERLEVEL9k_DIR_HOME_BACKGROUND='black'
POWERLEVEL9k_DIR_HOME_FOREGROUND='white'
POWERLEVEL9k_DIR_HOME_SUBFOLDER_BACKGROUND='black'
POWERLEVEL9k_DIR_HOME_SUBFOLDER_FOREGROUND='white'
POWERLEVEL9k_DIR_DEFAULT_BACKGROUND='yellow'
POWERLEVEL9k_DIR_DEFAULT_FOREGROUND='black'
POWERLEVEL9k_DIR_SHORTEN_LENGTH=2
POWERLEVEL9k_DIR_SHORTEN_STRATEGY="truncate_from_right"

# OS segment
POWERLEVEL9k_OS_ICON_BACKGROUND='black'
POWERLEVEL9k_LINUX_ICON='%F{cyan} \uf303 %F{white} arch %F{cyan}linux%f'

# VCS icons
POWERLEVEL9k_VCS_GIT_ICON=$'\uf1d2 '
POWERLEVEL9k_VCS_GIT_GITHUB_ICON=$'\uf113 '
POWERLEVEL9k_VCS_GIT_GITLAB_ICON=$'\uf296 '
POWERLEVEL9k_VCS_BRANCH_ICON=$''
POWERLEVEL9k_VCS_STAGED_ICON=$'\uf055'
POWERLEVEL9k_VCS_UNSTAGED_ICON=$'\uf421'
POWERLEVEL9k_VCS_UNTRACKED_ICON=$'\uf00d'
POWERLEVEL9k_VCS_INCOMING_CHANGES_ICON=$'\uf0ab '
POWERLEVEL9k_VCS_OUTGOING_CHANGES_ICON=$'\uf0aa '

# VCS colours
POWERLEVEL9k_VCS_MODIFIED_BACKGROUND='blue'
POWERLEVEL9k_VCS_MODIFIED_FOREGROUND='black'
POWERLEVEL9k_VCS_UNTRACKED_BACKGROUND='green'
POWERLEVEL9k_VCS_UNTRACKED_FOREGROUND='black'
POWERLEVEL9k_VCS_CLEAN_BACKGROUND='green'
POWERLEVEL9k_VCS_CLEAN_FOREGROUND='black'

# VCS CONFIG
POWERLEVEL9k_VCS_SHOW_CHANGESET=false

# Status
POWERLEVEL9k_STATUS_OK_ICON=$'\uf164'
POWERLEVEL9k_STATUS_ERROR_ICON=$'\uf165'
POWERLEVEL9k_STATUS_ERROR_CR_ICON=$'\uf165'

# Battery
POWERLEVEL9k_BATTERY_LOW_FOREGROUND='red'
POWERLEVEL9k_BATTERY_CHARGING_FOREGROUND='blue'
POWERLEVEL9k_BATTERY_CHARGED_FOREGROUND='green'
POWERLEVEL9k_BATTERY_DISCONNECTED_FOREGROUND='blue'
POWERLEVEL9k_BATTERY_VERBOSE=true

# Programming languages
POWERLEVEL9k_RBENV_PROMPT_ALWAYS_SHOW=true
POWERLEVEL9k_GO_VERSION_PROMPT_ALWAYS_SHOW=true

# User with skull
user_with_skull() {
echo -n "\ufb8a $(whoami)"
}
POWERLEVEL9k_CUSTOM_USER="user_with_skull"

# Command auto-correction.
ENABLE_CORRECTION="true"

# Command execution time stamp shown in the history command output.
HIST_STAMPS="mm/dd/yyyy"

# 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)

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='nano'
# 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"

`

@romkatv
Copy link

romkatv commented Jul 25, 2019

Your config is an important part of the issue but its formatting is all messed up. See https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code for how to format code with github-flavored markdown. Click "Preview" before submitting comments or issues to make sure the content is rendered as you expect.

@dbarrett24
Copy link
Author

Your config is an important part of the issue but its formatting is all messed up. See https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code for how to format code with github-flavored markdown. Click "Preview" before submitting comments or issues to make sure the content is rendered as you expect.

Thank you! sorry about the formatting! I just edited it!

@romkatv
Copy link

romkatv commented Jul 25, 2019

Thanks for fixing the formatting.

I'm going to try to reproduce it. I don't use the same setup, so it'll take me a bit of time. You've mentioned two separate problems:

  1. Changes to POWERLEVEL9K parameters in your ~/.zshrc have no effect on the appearance of your prompt.
  2. Your prompt looks a bit off.

I can see the evidence of (2) on your screenshot as some prompt segments seem to be missing background color.

Can you confirm (1)? If you delete all your POWERLEVEL9K parameters from your ~/.zshrc and type zsh, will your prompt still look the same?

@dbarrett24
Copy link
Author

Can you confirm (1)? If you delete all your POWERLEVEL9K parameters from your ~/.zshrc and type zsh, will your prompt still look the same?

Yes, i've tried to delete it all, save, open new terminal. Nothing changes. I've tried to change the theme in the .zshrc as well but nothing happens.

@romkatv
Copy link

romkatv commented Jul 26, 2019

I've managed to reproduce and fix both problems. For the first, copy-paste the following command into your terminal.

() {
  emulate -L zsh
  setopt err_return no_unset xtrace
  [[ -d ~/.oh-my-zsh ]] || {
    command git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
  }
  ( cd ~/.oh-my-zsh && command git pull )
  [[ -d ~/.oh-my-zsh/custom/themes/powerlevel10k ]] || {
    git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
  }
  ( cd ~/.oh-my-zsh/custom/themes/powerlevel10k && git pull )
  [[ ! -e ~/.zshrc ]] || mv ~/.zshrc $(mktemp -d "${TMPDIR:-/tmp}"/backup.XXXXXXXXXX)
  command cat >~/.zshrc <<END
# 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.
ZSH=~/.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"
POWERLEVEL9K_MODE='nerdfont-complete'

# DAVE'S CUSTOMIZATIONS - THEMING

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_user dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(background_jobs go_version rbenv)

# Prompt settings
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX_ICON=\$'%K{white}%k'
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX_ICON=\$'%K{green}%F{black} \uf155 %f%F{green}%k\ue0b0%f '

# Separators
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR_ICON=\$'\ue0b0'
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR_ICON=\$'\ue0b1'
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR_ICON=\$'\ue0b2'
POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR_ICON=\$'\ue0b7'

# Dir colours
POWERLEVEL9K_DIR_HOME_BACKGROUND='black'
POWERLEVEL9K_DIR_HOME_FOREGROUND='white'
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND='black'
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND='white'
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='yellow'
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='black'
POWERLEVEL9K_DIR_SHORTEN_LENGTH=2
POWERLEVEL9K_DIR_SHORTEN_STRATEGY="truncate_from_right"

# OS segment
POWERLEVEL9K_OS_ICON_BACKGROUND='black'
POWERLEVEL9K_LINUX_ICON='%F{cyan} \uf303 %F{white} arch %F{cyan}linux%f'

# VCS icons
POWERLEVEL9K_VCS_GIT_ICON=\$'\uf1d2 '
POWERLEVEL9K_VCS_GIT_GITHUB_ICON=\$'\uf113 '
POWERLEVEL9K_VCS_GIT_GITLAB_ICON=\$'\uf296 '
POWERLEVEL9K_VCS_BRANCH_ICON=\$''
POWERLEVEL9K_VCS_STAGED_ICON=\$'\uf055'
POWERLEVEL9K_VCS_UNSTAGED_ICON=\$'\uf421'
POWERLEVEL9K_VCS_UNTRACKED_ICON=\$'\uf00d'
POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON=\$'\uf0ab '
POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON=\$'\uf0aa '

# VCS colours
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='blue'
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='black'
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='green'
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='black'
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='green'
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='black'

# VCS CONFIG
POWERLEVEL9K_VCS_SHOW_CHANGESET=false

# Status
POWERLEVEL9K_STATUS_OK_ICON=\$'\uf164'
POWERLEVEL9K_STATUS_ERROR_ICON=\$'\uf165'
POWERLEVEL9K_STATUS_ERROR_CR_ICON=\$'\uf165'

# Battery
POWERLEVEL9K_BATTERY_LOW_FOREGROUND='red'
POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND='blue'
POWERLEVEL9K_BATTERY_CHARGED_FOREGROUND='green'
POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND='blue'
POWERLEVEL9K_BATTERY_VERBOSE=true

# Programming languages
POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=true
POWERLEVEL9K_GO_VERSION_PROMPT_ALWAYS_SHOW=true

# User with skull
user_with_skull() {
echo -n "\ufb8a \$(whoami)"
}
POWERLEVEL9K_CUSTOM_USER="user_with_skull"

# Command auto-correction.
ENABLE_CORRECTION="true"

# Command execution time stamp shown in the history command output.
HIST_STAMPS="mm/dd/yyyy"

# 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)

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='nano'
# 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"
END
  exec zsh
}

Make sure to copy-paste the whole thing, including the first and the last lines.

This will give you the same prompt as in Andrea's config.

Now to the background issue. Type sleep 3& to trigger background_jobs segment on the right. What you are seeing is that black background appears identical to no background. For example, the following two commands will produce identical output in Windows Terminal:

print -P '%K{black}test%k'
print -P 'test'

This is a bug in ConPTY that hopefully will eventually be fixed: microsoft/terminal#293.

A workaround is to avoid using black background. For example, try executing this command from your terminal:

POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND=8

This will fix background_jobs segment by making its background color grey. Type sleep 3& to confirm.

Since you are using Powerlevel10k, there is a much better solution than changing black background to grey. Use the recommended config. Copy paste the following command into your terminal window to see how Powerlevel10k looks with the recommended config.

unset -m 'POWERLEVEL9K_*'
source $ZSH_CUSTOM/themes/powerlevel10k/config/p10k-lean.zsh

By default it'll show few icons. To enable lots of icons, type this:

unset POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION

Want that user with skull on the left?

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(user $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS)
POWERLEVEL9K_USER_VISUAL_IDENTIFIER_EXPANSION=$'\uFB8A'

To permanently change your config to the default, type this:

cp $ZSH_CUSTOM/themes/powerlevel10k/config/p10k-lean.zsh ~/p10k.zsh
echo 'unset -m "POWERLEVEL9K_*"' >>~/.zshrc
echo 'source ~/p10k.zsh' >>~/.zshrc

You can remove all POWERLEVEL9K parameters from ~/.zshrc as they don't do anything now. To customize your prompt, edit ~/p10k.zsh. For example, remove the line that sets POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION to enable lots of icons.

Edit: You can now use p10k configure to configure Powerlevel10k. This is recommended over directly sourcing p10k-lean.zsh.

@romkatv
Copy link

romkatv commented Jul 26, 2019

@dbarrett24 I've edited commands in my reply. Make sure to copy-paste them from #1339 (comment) instead of an email if you've received one.

@cellcoresystems
Copy link

@dbarrett24 have you ever tried the great suggestion from @romkatv ?
Did it fix your problem ?

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

No branches or pull requests

3 participants