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 611df522 for ; Mon, 18 Nov 2019 14:19:49 +0000 (UTC) Received: (qmail 11526 invoked by alias); 18 Nov 2019 14:19:40 -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: 24446 Received: (qmail 29720 invoked by uid 1010); 18 Nov 2019 14:19:40 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f47.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25635. spamassassin: 3.4.2. Clear:RC:0(209.85.166.47):SA:0(-2.0/5.0):. Processed in 4.607478 secs); 18 Nov 2019 14:19:40 -0000 X-Envelope-From: roman.perepelitsa@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.166.47 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=SOjACXbXnd0qgj7S4PKlLUabzO01Ok8ndLF36Bp5Uig=; b=m7efI1K5rReJSjx6lfTkUZsWhJLq3T1VVcczoJHbocbFyQN5xlTpR2H7bupZal8j1J OfEPHVljYnk5pFOq8n3txnl+rL1e85sbjGg5/gd0FxjLeQ16Tfu1uJkBzgJHt+7o0Rd2 xVuubRO7RA7bZ3zvmmnY/uBKX0jaNkI0buxVJPBlOSRJ3fJ9a7gTFSSKWDhC8HbnHrNM vwRT4Cv2Y9oVSq+dNdt5Kv197BcAkBomuS7KMfL6QvkXTGWbNVsCwBV6DLcxpx/JFleS dYuDBgrIbAJG7A7EeJd/+5wtxrhN1u2xjsWApHyvDnQAu0LiCIefj63s0KWF1FQQjkcT gUBg== 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=SOjACXbXnd0qgj7S4PKlLUabzO01Ok8ndLF36Bp5Uig=; b=H52FS9DfzAN6zNSlpEwjbJWcBxXmKLuE9AWYz0+2oQaNm+bzIFfYgFj8R33FqRLNBl NCdT4/b6RvCM6Bm3Gy+A+BeeL1I6mZyh71XvzT1j/oceCabTCL7LX3jCTSLG8W95jE+D TEsCX+7+2LqlBMGSC88F/seUCXCh7+pPgDXAUxVzLO5lBzUIYkVvzcE0Y5yZJgnSsbQr 5xbRGGRXFaeb4N+qLS82g7C3IZ/XscFSWOUWyoDwzS74/9uOnHaqXSlB+Wrcwnu8rwBo UD+sgfMwtQP4lhp3wyEALWBSffBRUgekSUzgB922v1tix+VQF8erUYTwvmPPLXmScAvz ryug== X-Gm-Message-State: APjAAAW/arP+8PhQYTNV4NHZxcaunxgDUh8BdW2XtZbkTJ98uichykoC dJ0MlIgVYm+No77gsOnutUI81/Y4u18Vikf0yDjh6vlI X-Google-Smtp-Source: APXvYqwjG+FQ7HHpcuD+GRcpLxn5yut1mpxEz9batZUmqAAvGpTv9/IziKAC80vbyO5tiamSIR2cQ4VgFf8ucylhd0A= X-Received: by 2002:a02:c4cd:: with SMTP id h13mr13970163jaj.33.1574086741115; Mon, 18 Nov 2019 06:19:01 -0800 (PST) MIME-Version: 1.0 From: Roman Perepelitsa Date: Mon, 18 Nov 2019 15:18:50 +0100 Message-ID: Subject: RFC: Generalized transient_rprompt To: Zsh Users Content-Type: text/plain; charset="UTF-8" I've mentioned in workers/44905 that I was looking for a way to implement generalized transient_rprompt. The goal is to not only hide right prompt when accepting a command line (like transient_rprompt does) but to shorten left prompt, too. Regular behavior with PROMPT='%~%# ' and RPROMPT='%n@%m': /tmp% echo hello romka@adam hello /tmp% true romka@adam /tmp% romka@adam With transient_rprompt option set: /tmp% echo hello hello /tmp% true /tmp% romka@adam With left prompt shortened down to `%#`: % echo hello hello % true /tmp% romka@adam I've found what appears to be a robust implementation that achieves this effect and am looking for feedback. Here it is: zle-line-init() { emulate -L zsh [[ $CONTEXT == start ]] || return 0 while true; do zle .recursive-edit local -i ret=$? [[ $ret == 0 && $KEYS == $'\4' ]] || break [[ -o ignore_eof ]] || exit 0 done local saved_prompt=$PROMPT local saved_rprompt=$RPROMPT PROMPT='%# ' RPROMPT='' zle .reset-prompt PROMPT=$saved_prompt RPROMPT=$saved_rprompt if (( ret )); then zle .send-break else zle .accept-line fi return ret } zle -N zle-line-init I've found one case where this implementation behaves differently from transient_rprompt. When a background job completes, normally a notification would appear right away and prompt together with the current command line would be reprinted. My implementation will prevent the notification from being shown until the current line is finished. Is there a way to fix this discrepancy? Are there other cases where this implementation behaves differently from transient_rprompt? Roman.