romkatv / powerlevel10k

A Zsh theme
MIT License
46.64k stars 2.19k forks source link

tmux: creating new windows or (split window) panes. #2766

Closed ravensorrow closed 1 month ago

ravensorrow commented 1 month ago

I noticed over the last 2 days, while I was refining my .zshrc, that when I created new tmux windows or panes w/i tmux, that pl10k pukes all over my console with the following message,

[WARNING]: Console output during zsh initialization detected.

When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.

You can:

  - Recommended: Change ~/.zshrc so that it does not perform console I/O
    after the instant prompt preamble. See the link below for details.

    * You will not see this error message again.
    * Zsh will start quickly and prompt will update smoothly.

  - Suppress this warning either by running p10k configure or by manually
    defining the following parameter:

      typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet

    * You will not see this error message again.
    * Zsh will start quickly but prompt will jump down after initialization.

  - Disable instant prompt either by running p10k configure or by manually
    defining the following parameter:

      typeset -g POWERLEVEL9K_INSTANT_PROMPT=off

    * You will not see this error message again.
    * Zsh will start slowly.

  - Do nothing.

    * You will see this error message every time you start zsh.
    * Zsh will start quickly but prompt will jump down after initialization.

For details, see:
https://github.com/romkatv/powerlevel10k#instant-prompt

-- console output produced during zsh initialization follows --

If I open a new terminal window from my terminal client, that error message doesn't appear, and it doesn't appear the first time tmux is called to replace the already running shell. Is there something special that has to be done w/ either zsh or powerlevel10k that I am not aware of?

ravensorrow commented 1 month ago

My .zshrc for context is as follows.

# eval $(keychain --eval ~/.ssh/github.com)

# 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

# PATH
PATH=$PATH:/usr/local/go/bin

# Dir to store zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"

# Download zinit, if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
  mkdir -p "$(dirname $ZINIT_HOME)"
  git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi

# Source/Load zinit
source "${ZINIT_HOME}/zinit.zsh"

# Add in Powerlevel10k
zinit ice depth=1; zinit light romkatv/powerlevel10k

# Add in zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab

# Add in snippits (ohmyzshell plugins)
zinit snippet OMZP::git
zinit snippet OMZP::sudo
zinit snippet OMZP::command-not-found
zinit snippet OMZP::colored-man-pages
zinit snippet OMZP::colorize
zinit snippet OMZP::hitchhiker
zinit snippet OMZP::rust
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/ssh-agent
#zinit snippet OMZP::ssh-agent
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/ssh
#zinit snippet OMZP::ssh

# Load ZSH Color Style
ZSH_COLORIZE_STYLE="colorful"

# Load zsh-completions
autoload -U compinit && compinit

zinit cdreplay -q

# Investigate zini plugin Starship.rs

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

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

# Keybindings
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward

# command history
HISTSIZE=5000
HISTFILE=~/.zsh/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups

# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
#zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
#zstyle ':omz:plugins:ssh-agent' quiet yes
#zstyle ':omz:plugins:ssh-agent' lazy yes

# Source/Load other files.
source ${HOME}/.zsh/.zshrc_aliases

# Shell integrations
eval "$(fzf --zsh)"
eval $(keychain --eval ~/.ssh/github.com)
#eval "$(zoxide init --cmd cd zsh)"
eval $HOME/bin/vfd
romkatv commented 1 month ago

When you see that warning, what is the output of typeset -p P9K_STARTUP_CONSOLE_OUTPUT?

ravensorrow commented 1 month ago

OK, so I figured this out with your response. It was a combination of keychain and VFD (a local script of fortune from a specific file and then pipped to cowsay). I moved them to the top, and the problem appears to have resolved itself.

ravensorrow commented 1 month ago

When you see that warning, what is the output of typeset -p P9K_STARTUP_CONSOLE_OUTPUT?

This would be a good diagnostic tool to list in the above error message to help diagnose a problem like this.

romkatv commented 1 month ago

Wasn't there anything below the "-- console output produced during zsh initialization follows --"? I just assumed you cut out the important part when filing the issue.

ravensorrow commented 1 month ago

No, it was just my prompt at that point. I figured my themed prompt wasn't necessary for the issue lol.

romkatv commented 1 month ago

When you see that warning, what is the output of typeset -p P9K_STARTUP_CONSOLE_OUTPUT?

What is the answer to this question then?

ravensorrow commented 1 month ago

'Keychain' and 'fortune' produced output at console initialization, which was producing the output interfering with the pl10k instant prompt, and moving these to before pl10k's instant prompt initialization resolved the problem.

romkatv commented 1 month ago

When you see that warning, what is the output of typeset -p P9K_STARTUP_CONSOLE_OUTPUT?

This would be a good diagnostic tool to list in the above error message to help diagnose a problem like this.

I'm trying to address this suggestion of yours. It would be a lot easier if you could answer my question.

ravensorrow commented 1 month ago

I apologize; I misunderstood. The suggestion being 'typeset -p P9K_STARTUP_CONSOLE_OUTPUT' would be good to have printed in the pl10k instant prompt error message. This immediately allowed me to correct my issues and I thought this would be useful for others to self-diagnose.

romkatv commented 1 month ago

No need to apologize.

I give up though.