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

autoload theme doesn't work #43

Closed
zfben opened this issue Dec 18, 2021 · 18 comments
Closed

autoload theme doesn't work #43

zfben opened this issue Dec 18, 2021 · 18 comments

Comments

@zfben
Copy link

zfben commented Dec 18, 2021

Describe the bug

I want to load a theme when opening a new terminal, is autoload do that?

To Reproduce

I have tried zpm load romkatv/powerlevel10k,autoload and zpm load @theme/romkatv/powerlevel10k,autoload

They just work in the current shell.

Expected behavior

Autoload without inputting commands.

Additional context

@grigorii-horos
Copy link
Member

Hey @zfben.

  • Autoload works with autoloadable functions in next way autoload=function1,function2, not just autoload. Maybe do you mean async? This theme doesn't provide something like this, so you can remove autoload tag
  • Are you saved this in your .zshrc?

@zfben
Copy link
Author

zfben commented Dec 19, 2021

@grigorii-horos I tried to run zpm load romkatv/powerlevel10k,async, it only works on the current shell.
Then I tried to add this command to .zshrc, it showed the theme in a second and then restored to default.

I want to set powerlevel10k as zsh's default theme.

@grigorii-horos
Copy link
Member

I think you should load this theme in sync mode

Add this into your .zshrc

zpm load romkatv/powerlevel10k

@zfben
Copy link
Author

zfben commented Dec 19, 2021

I think you should load this theme in sync mode

Add this into your .zshrc

zpm load romkatv/powerlevel10k

@grigorii-horos I tied it, but it now works :(

The .zshrc content is:

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

if [[ ! -f ~/.zpm/zpm.zsh ]]; then
  git clone --recursive https://github.com/zpm-zsh/zpm ~/.zpm
fi
source ~/.zpm/zpm.zsh

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

zpm load romkatv/powerlevel10k

Is it something wrong?

@grigorii-horos
Copy link
Member

Hey @zfben . I found a bug in romkatv/powerlevel10k. You can use my temporary fork of this repo: zpm-zsh/powerlevel10k

@zfben
Copy link
Author

zfben commented Dec 20, 2021

It dosen't work.

My steps are:

  1. run zpm load zpm-zsh/powerlevel10k
  2. write the command to .zshrc

Now my .zshrc is:

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
# if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
#  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
# fi

if [[ ! -f ~/.zpm/zpm.zsh ]]; then
  git clone --recursive https://github.com/zpm-zsh/zpm ~/.zpm
fi
source ~/.zpm/zpm.zsh

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

zpm load zpm-zsh/powerlevel10k

@grigorii-horos
Copy link
Member

@zfben What error do you have? I tried your zshrc and it's works
https://asciinema.org/a/a2Q5Ku0ztNGLgYSmlEqorXM0R

@zfben
Copy link
Author

zfben commented Dec 20, 2021

@grigorii-horos i forgot to run zpm clean. it works now, thank you.

@zfben zfben closed this as completed Dec 20, 2021
@zfben zfben reopened this Dec 20, 2021
@zfben
Copy link
Author

zfben commented Dec 20, 2021

@grigorii-horos by the way, could you create a pull request to powerlevel10k? then I can use the official powerlevel10k source.

@grigorii-horos
Copy link
Member

grigorii-horos commented Dec 20, 2021

Hey @zfben I tried, but author doesn't want to accept pr

romkatv/powerlevel10k#1678

You can add a comment here, I think

@zfben
Copy link
Author

zfben commented Dec 20, 2021

Hmm, I don't good at zsh, I guess the author thinks the source changes maybe make it more complex or bugs.

@grigorii-horos
Copy link
Member

Hey @zfben . I did another fix for this issue. Now zpm load romkatv/powerlevel10k should work fine. Try to run

zpm update

@zfben
Copy link
Author

zfben commented Dec 25, 2021

When i ran zpm update, it shows Unknown command zpm update, treat as zpm load update Skip install update ✖

Then I goto ~/.zpm and git pull directly.

After I run zpm load romkatv/powerlevel10k and zpm clean, then I open a new shell, it shows no such file or directory: /private/var/folders/r9/4jr03m4169xfqm2sgg7j_dd40000gn/T/zsh-501/internal/p10k.zsh.

Now the .zshrc is:

if [[ ! -f ~/.zpm/zpm.zsh ]]; then
  git clone --recursive https://github.com/zpm-zsh/zpm ~/.zpm
fi
source ~/.zpm/zpm.zsh

export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

zpm load romkatv/powerlevel10k
#source ~/powerlevel10k/powerlevel10k.zsh-theme
zpm load zfben/zsh-npm

@grigorii-horos
Copy link
Member

@zfben Sorry... Use zpm upgrade. I forgotten own function name 😹

@zfben
Copy link
Author

zfben commented Dec 25, 2021

After i run zpm upgrade, it shows same error in new terminal.

@jqhr
Copy link

jqhr commented Feb 10, 2022

@grigorii-horos
I delete /tmp/zsh-1000/zpm-cache.zsh, it works

@dakky
Copy link

dakky commented Jan 29, 2023

so basically this issue still exists. Are there any plans to fix that?

the recent state is:
after installing/cleaning/upgrading the theme there is an error with anon):source:27: no such file or directory: /tmp/zsh-1000/internal/p10k.zsh

deleting this folder fixes the issue until next update/clean/ (so it seems)

EDIT: no it breaks even on a new shell => this thema can not be loaded bei zpm :-(

@grigorii-horos
Copy link
Member

@dakky @zfben Please add this before powerlevel10k init

export POWERLEVEL9K_INSTALLATION_DIR=~/.zpm/plugins/romkatv---powerlevel10k

# powerlevel10k init
zpm load romkatv/powerlevel10k

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

4 participants