help / Atom feed
* Cool presentation of Asynchronicity, a recent buzz-word in Zsh topic
@ 2018-10-24  8:43 Sebastian Gniazdowski
  0 siblings, 0 replies; 1+ messages in thread
From: Sebastian Gniazdowski @ 2018-10-24  8:43 UTC (permalink / raw)
  To: Zsh Users

from some time (1 or 1.5 years?) there's the topic of async-operation
in Zsh plugins. There's the plugin mafredri/zsh-async, which uses
module zsh/zpty to run background task and return via zle -F handler.

I've discovered that <( ) is a good method to run background task. It
is simpler than using an API of a plugin and very simple in general.
Three lines of code are needed to run a task in background:

            exec {ZTSFD}< <(LANG=C sleep 0.3; print -r -- $CUR_SECONDS)
            command true # workaround Zsh bug
            zle -F -w "$ZTSFD" zts_postponed_redisplay

After that, after 300 ms, zts_postponed_redisplay() will be called (if
the command line is unused, free), with stdin plugged so that it can
read $CUR_SECONDS. There's Zsh bug, and a risk of segfaults, I wasn't
able to track this fully (only found the workaround), but I've made a
plugin that makes intense use of <( ), and here's the result (the
presentation of async-work) – smooth operation without problems:


Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24  8:43 Cool presentation of Asynchronicity, a recent buzz-word in Zsh topic Sebastian Gniazdowski


Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/ public-inbox