Skip to content

Commit 482b35a

Browse files
committed
Try using named pipe
1 parent 1906ad8 commit 482b35a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

agkozak-zsh-prompt.plugin.zsh

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979

8080
# EPOCHSECONDS is needed to display command execution time
8181
(( $+EPOCHSECONDS )) || zmodload zsh/datetime
82+
zmodload -F zsh/files b:zf_rm
8283

8384
autoload -Uz is-at-least add-zle-hook-widget
8485

@@ -732,8 +733,10 @@ _agkozak_async_init() {
732733
# then kill own process, sending SIGUSR1
733734
############################################################
734735
_agkozak_usr1_async_worker() {
736+
# Make a named pipe
737+
mkfifo /tmp/agkozak_zsh_prompt_$$
735738
# Save Git branch status to temporary file
736-
_agkozak_branch_status >| /tmp/agkozak_zsh_prompt_$$
739+
_agkozak_branch_status >| /tmp/agkozak_zsh_prompt_$$ &
737740

738741
# Signal parent process
739742
kill -s USR1 $$ &> /dev/null
@@ -754,6 +757,8 @@ _agkozak_async_init() {
754757
# Set prompts from contents of temporary file
755758
_agkozak_set_git_psvars "$(< /tmp/agkozak_zsh_prompt_$$)"
756759

760+
zf_rm /tmp/agkozak_zsh_prompt_$$
761+
757762
# Reset asynchronous process number
758763
AGKOZAK[USR1_ASYNC_WORKER]=0
759764

0 commit comments

Comments
 (0)