zimfw / git-info

Exposes git repository status information to prompts.
MIT License
6 stars 4 forks source link

prompt hangs when verbose is enabled #2

Closed dmaes closed 2 years ago

dmaes commented 2 years ago

Describe the bug
Shell hangs after executing a command inside a git repository, prompt is not shown

Steps to reproduce
The fist 4 steps restart the shell with a clean installation of Zim in a temporary directory. Use exec zsh when restarting the terminal or restarting the shell is needed.

  1. cd ${$(mktemp -d):A}
  2. ZDOTDIR=${PWD} HOME=${PWD} ZIM_HOME=${PWD}/.zim exec zsh
  3. curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
  4. exec zsh
  5. Use following config:
    zstyle ':zim:git-info' verbose yes
    zstyle ':zim:git-info:branch' format '%b'
    zstyle ':zim:git-info:commit' format '%c'
    zstyle ':zim:git-info:clean' format '%F{green}'
    zstyle ':zim:git-info:dirty' format '%F{yellow}'
    zstyle ':zim:git-info:keys' format 'prompt' ' %F{blue}git:(%F{cyan}%C%D%b%c%F{blue})%f'

Current behavior
Shell hangs after executing a command inside a git repository, prompt is not shown

Expected behavior
Prompt is shown

zimfw info

zimfw version: 1.9.1 (built at 2022-05-24 21:25:10 UTC, previous commit is 5bcfb8c)
ZIM_HOME:      /home/dmaes/.config/zim
Zsh version:   5.9
System info:   Linux inuits-t490 5.19.2-1-default #1 SMP PREEMPT_DYNAMIC Thu Aug 18 05:06:49 UTC 2022 (6c252ef) x86_64 x86_64 x86_64 GNU/Linux

Additional context
While debugging, it seems the problem lies with the asynchronously running of $cmds. Hanging happens when $cmds is empty. As much as adding a simple /bin/true to the $cmds array when in the if ! zstyle -t ':zim:git-info' verbose else-block fixes this.

ericbn commented 2 years ago

Hi @dmaes. Good catch! I can reproduce it replacing the zstyle defininions in ~/.zim/modules/asciiship/asciiship.zsh-theme by the ones you provided.

dmaes commented 2 years ago

Thanks :)