From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 260b143a for ; Sat, 22 Jun 2019 17:18:31 +0000 (UTC) Received: (qmail 18365 invoked by alias); 22 Jun 2019 17:18:23 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23980 Received: (qmail 12523 invoked by uid 1010); 22 Jun 2019 17:18:23 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi1-f169.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25482. spamassassin: 3.4.2. Clear:RC:0(209.85.167.169):SA:0(-2.0/5.0):. Processed in 2.353467 secs); 22 Jun 2019 17:18:23 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.167.169 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=inrTGEBWNyiHqdeYuP/dLu8yBbYyyhlShF8KMug7ZTE=; b=KQ6VYiUHU6dmpIutAkz53dHX+adn00Ur510Pe5TxATtkrse4u3C/K9TeaKeGpWr1+V 4QvuD3SE6T+8uOCfAy/rmtMnO+JwhcGDrFvpjP3Ds7xbMU9CUl3t8X/p3tHT2vnlmEA/ jwuJ/H1yrkzUUcg6nwCg2NAaD6uuSw1q5SELO8vznW4KbfCtDwx67J/5OlsNbxQYHosx +MgWj1RA6K0pQ+4RrvG/lArdriexTY6GGDH40gR/UaxVXaiF55k3UVXdUt8FQTRQsYgX QtcDTAd65sUx8NXYT1yfaYMqtP4s8z2C21SlkyH6lPrKDmzp1ScIPNUjPt/DKOaxPpmg hY1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=inrTGEBWNyiHqdeYuP/dLu8yBbYyyhlShF8KMug7ZTE=; b=ompGrlUXD65Ez1uhU9MeoPUObV/XagsCkIXHdfSCHBmswsiyDs/39UfSN3WOZBHynp 2bpEpODYmYA/RW0zjxrWhMYebrjYk0mB0j/xYYDNW2ejwdB2XUq3hFlAbmmDxCRoXLqX 3W28MdWQZGIeub2p72owL6V/10PwxrL1q+XyZpIvHAtxk8eC0ITmWMrmjiDtmpYTaGq3 j9s7knoyfhligOlvLBGsWFkR66sql1Yg24Ynsg6fn5bvPW0xOPkYhIkjvgqCl5dC6Pzm h67PvQ4Pthz4Gpr3wNlCQ1y16GIjgVdlxdmwvw4d820h78E8HsLBj1MZ/gaMDwMZEDHr EujA== X-Gm-Message-State: APjAAAX5EDTR6Qu7rcsL967YPsiX0JuMtNNIe/M6e6f6EM8k4KeGPapi i7WNUs8aKet+vhPNMz/I96M1P3j1fhqArK72tnLhk7G5 X-Google-Smtp-Source: APXvYqzmH3MDDtmGMvM5iEhjeZl92FWG7RIaEJO37Vg1qSpOx/D6Fwi76FHdjxdojE0pEe8H3GSGP2yXMO0PdKSwnhQ= X-Received: by 2002:aca:1a0e:: with SMTP id a14mr5794304oia.51.1561223867678; Sat, 22 Jun 2019 10:17:47 -0700 (PDT) MIME-Version: 1.0 From: Sebastian Gniazdowski Date: Sat, 22 Jun 2019 19:17:36 +0200 Message-ID: Subject: A function to display message under the prompt without zle active To: Zsh Users Content-Type: text/plain; charset="UTF-8" Hello, I've forged as I think an interesting function, which will display given message under the prompt regardless if ran from within zle or not. It uses the exec <(...) / zle -F trick to dispatch a callback that does have the zle active (zle -F -w isn't needed, zle -M works fine from no-widget callback): # deploy-message Hello world # deploy-message @sleep:5.5 "Hello world" deploy-message() { [[ "$1" = <-> && ${#} -eq 1 ]] && { zle && { local alltext text IFS=$'\n' nl=$'\n' repeat 25; do read -u"$1" text; alltext+="${text:+$text$nl}"; done [[ -n "$alltext" ]] && zle -M "$alltext" } zle -F "$1"; exec {1}<&- return 0 } local THEFD # The expansion is: if there is @sleep: pfx, then use what's after # it, otherwise substitute 0 exec {THEFD} < <(LANG=C sleep $(( 0.01 + ${${${(M)1#@sleep:}:+${1#@sleep:}}:-0} )); print -r -- ${1:#(@msg|@sleep:*)} "${@[2,-1]}") zle -F "$THEFD" -deploy-message } There's a gist with the function as well, in case of any updates: https://gist.github.com/psprint/b6503c0c37de483f68d055e9c47981b3 -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org