From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30394 invoked from network); 30 Dec 2022 05:38:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 30 Dec 2022 05:38:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1672378690; b=XhBy+FHZnMjCcY8OcJnPM33t1ayRk7h2WrzMKGJkOu6sBw/4FN228+SyUSEw4Y0cO2OOAFGlng yQZf81ubp/i0KiFDusjvIsmBpBGxkYRzQyHLJ/rMMrk3HKhFYUfxBSkcvonfXLlJEf9JMcf20J vM+ox3cgAAN4gT+ci9z/QPD9EjLAIQT/3vMU+9RTbg4wErsyeGZuS8AGDOJKcGpXuDZellpQw4 rH2lU5rN8CbZZtILLqw/3He3h3rqmtAnzy6DhtNMdw06/cl4mjyZOiSi7d8NDbCme5axolUFXh QPSS7L/mI+bKBnj2K48XHWdkgk79jJZgsbTAkv37Oly/0A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pj1-f51.google.com) smtp.remote-ip=209.85.216.51; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1672378690; bh=jT7lHn7EZfs6s4fZZ9Btm5Sz1a0xGujq86NKDz4NYSE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=D4gWxj7G28IEX74xALcppfwUcXC+SMBgnx9OkR5UT8gptgzBtbWtQEwp3dmCjdauTba9IAx5nD pfxo9Xd3TPa7fv3Y+rh6cRwfzFjcHRA0p0GS9UOH7pUmjTZ2rZfFEFNNl33cA1Bt8xOi9ELODc 2/VFucplQXjD8qqtQ7SrXMa94IbEe0w6bA5U/6t1u6OtgwqgUEhdsFxsaNZ6bAeARx9s1E+6Ay FwnmgUieDYs0KvoXqchf1Renop60Hp+D4hONU8Vr3p860iSKK0aveGZfZB5c7GzMexMAPXnC53 /HIcLiALWwsgq2bGjrFSExLF+aBnu7baqpsnhelLK2YV7w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:MIME-Version:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=jT7lHn7EZfs6s4fZZ9Btm5Sz1a0xGujq86NKDz4NYSE=; b=lU7gkF1thWDfKRKEM/6uQSsJLN ePJI9tt717SfGY1gwCYFDjKclILz6+FrnzaAKSB7KE4hKikiiLx5XdmHpsD4lu1Dwpwho8mj8vkHO xd28qw+cou8nQq4KCv7f2sFEWy1JeeYVJYAWvC0kPGu46o+nRixHvgLU/+cEtLUGILj3n0ntSL7+Y gz6UrcY1Wl/2jKKSbRGP+aZVm4EHJ3MTLLI26ittnQIaBy7/xnYFijsmwne0jTSTmnAraA7mUJOKi w51RSaW8HpVyjZoDrUb4NbE5AD6om/lMey/I7h6/NLnxT9KNl7G/rOV6OaKbFXyOpATIAXL+XVaOZ J7k3b8+Q==; Received: by zero.zsh.org with local id 1pB85o-0008eK-L9; Fri, 30 Dec 2022 05:38:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pj1-f51.google.com) smtp.remote-ip=209.85.216.51; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pj1-f51.google.com ([209.85.216.51]:45718) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pB85D-0008Kc-HW; Fri, 30 Dec 2022 05:37:32 +0000 Received: by mail-pj1-f51.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so20790981pjj.4 for ; Thu, 29 Dec 2022 21:37:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=jT7lHn7EZfs6s4fZZ9Btm5Sz1a0xGujq86NKDz4NYSE=; b=lpTvgsQ2RrEZncv8jhRDfLRlsmg2FUQJ/N1IClC//BJfNHJVZAxMwXY12jH6/IZMHW jgFOlCAV5wMvqPY27QDShsUFW863MPljY0/11k0TLYTiAUD8CkwJzWlDfwDBI0+8Pqzx jaGmiz4CFyd7WxC9GYPETubuTp2uzuuyVg4NzayclDARBnoskfOJi5pnJYjAPn4qkrav PyZV7Vnd+VPcOshF/UHxFbh+LohF5PAW0zZU+FbSUq3OlQ4wl1NED4GG5SPlART3QNCd mPfs3E/pQb9eVMFtzbR0ZhTkM9+gIMd22O5R4tsYyWqwFPYqoEDGn2QgTcba0gYrPLGB nIVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jT7lHn7EZfs6s4fZZ9Btm5Sz1a0xGujq86NKDz4NYSE=; b=qhmGyX9fU/T6IcLjIXo6q1XTYF0m0x6ftFuY7wDbla7LNrG2zuD4t3/7qwa6L67XVw sr2OzZ16X1r8z674WYokS5/yCik9mXq58F6Vvb6xRJTRrS0Vhtt+x8xt6zF7qH8QRNpS 1eN+405CwCwqpqNkUhv+q+UaldEPNNXBwcv0KcfDfx49q3rApvMzD+pNUv1dwkPK4mfL 2NU1pAlE5CbRIvtcvKrJUBFWTvwz+2d+OBjvS+Ky8hQMRLNCVoJOMyHmqGXjEllnl5Dz 08zgcMaGu3EsgEtIx2BOvyho5TO+RfwnVX7e4lI/rN8WFCm1B9A6hyfMlGSi6PFE26n/ NVrw== X-Gm-Message-State: AFqh2kpqxLFGygD7vEgCoHUw9gObTZ+u+2nvPFDpbLmpFWzq5rkyWtp6 XqTfQQICpNi/2t/3N44wzSKpAVm1liWdGhTUrIMrpIvoD8KuczG/iG/jUA== X-Google-Smtp-Source: AMrXdXvwnKecdVCrqFZmH2UUrpWEYNTItkjgVRQAlFb5txOdYtTOSP/FR5k3OZHH3xCskg6Vn5Z/G1KdLXwm9oce9xI= X-Received: by 2002:a17:90a:ab89:b0:213:9df5:43b2 with SMTP id n9-20020a17090aab8900b002139df543b2mr2486490pjq.86.1672378649966; Thu, 29 Dec 2022 21:37:29 -0800 (PST) MIME-Version: 1.0 From: OG Code Poet Date: Thu, 29 Dec 2022 21:37:18 -0800 Message-ID: Subject: Read a line from user without clearing screen below the prompt while allowing user to use arrow keys to make edits in middle of line To: zsh-workers@zsh.org Cc: OG Code Poet Content-Type: multipart/alternative; boundary="0000000000005c7f8805f104ff7b" X-Seq: 51259 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000005c7f8805f104ff7b Content-Type: text/plain; charset="UTF-8" Using Bash ``tput cup 0 0; read -e -p "Enter input: " userinput`` works well for getting a line of user input: * It does not clear screen below the prompt * It allows user to use arrow keys to go to middle of line and edit a mistake they might have made while typing How can this be achieved in zsh? I have tried two techniques; either it clears screen below prompt or it does not allow using arrow to go back to middle of line to edit it. 1. Using ``vared``: ``` tput cup 0 0; userinput=""; vared -p "Enter input: " userinput ``` ``vared`` seems to clear screen below the prompt, so this clears the entire screen before showing the prompt. 2. Using ``read``: ``` tput cup 0 0; printf "Enter input: "; read -r userinput ``` This does not clear the screen below the prompt, but does not allow using arrow keys to go to middle of the line and make an edit ("delete" key works, but is too much to ask users to delete and retype everything from the point of typo). Is there a way out? Perhaps it could be possible to trick vared to believe there are no lines below, so it clears just 1 line (the line of prompt). If it is not possible in zsh, I am open to an external POSIX way of getting user input on first line of the screen. P.S. Also posted in unix.stackexchange.com: https://unix.stackexchange.com/q/730022/456507 --0000000000005c7f8805f104ff7b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Using Bash ``tput cup 0 0; read -e -p "Enter input: &= quot; userinput`` works well for getting a line of user input:

* It = does not clear screen below the prompt
* It allows user to use arrow key= s to go to middle of line and edit a mistake they might have made while typ= ing

How can this be achieved in zsh? I have tried two techniques; ei= ther it clears screen below prompt or it does not allow using arrow to go b= ack to middle of line to edit it.

1. Using ``vared``:
```
tput= cup 0 0; userinput=3D""; vared -p "Enter input: " user= input
```
``vared`` seems to clear screen below the prompt, so this c= lears the entire screen before showing the prompt.

2. Using ``read``= :

```
tput cup 0 0; printf "Enter input: "; read -r use= rinput
```
This does not clear the screen below the prompt, but does = not allow using arrow keys to go to middle of the line and make an edit (&q= uot;delete" key works, but is too much to ask users to delete and rety= pe everything from the point of typo).

Is there a way out? Perhaps i= t could be possible to trick vared to believe there are no lines below, so = it clears just 1 line (the line of prompt). If it is not possible in zsh, I= am open to an external POSIX way of getting user input on first line of th= e screen.

--0000000000005c7f8805f104ff7b--