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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26838 invoked from network); 25 May 2022 08:50:12 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 May 2022 08:50:12 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653468612; b=mQh/udPNMNSO5SqoTWnI/rcPqsVarajvTzkOmJ2FzOgxXWw0MMb+5CRO8OlYAzHfCZpXjXRSou 4u2rU8Mqox4rVDUwZLMRBN2j27ecXDPcA4+30GW8MBE07w1Njd2HV6B4ZWtasjOF68aGlhNOqn Q0UqF6dX85y3LYp19prsM12MRH9IgpOtNt16chNMpf6mPLPGT6gP+Pca+f+VhEUWqHiRYDIz0E HiWCcoVra2bWBHtKFolS8ZzVPlUXkzbq2GNrpo476SIXSv1kPSy76kkt9S9BF2YTw/qQEVmhWf +EPLz6zap0VeyazNxkajLLzcDcIoLwlw7SyxuR4IggFaVA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1653468612; bh=/oBpa8OpM8jYeMSAeiyXPyvV3oIcWt7EZnv8GBuZ2Yc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=G4SUzGb3WDcjT79yIdr/RLBj71iF/8Fnn/C7eCeyk6Wpe5Rh6+gwHehSnYG+DUEpOig5Pxi9td Ate0sF98N7akBF3p7NnBYpqoKKomS5i+IUKukzGVO0VwKpLhZOvtPyRcPo3rLwFPK5nkr5Nfnx xIxnbRnyTh8MqsrsWMwgv2xWLxzd7FsUV7r4TGbbw8ARN2n80yZMSyK39YuM5VaxBYOa6o3+11 sX5jck6d739ewf7utgIhOPjL+mxKk+xQMGvDCWMUK1T1TPv0flsL1cQ6VOlqIO1f6ArU/vw4gv 02M6KkeyZPlFZu0Jj4KQrJq2Ry9TS42hXNhXIyjbIpbu0A==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=HbiDBOJ1QZOBckCFC7rSXS6X7jzTx3AyWlUkBzdUd/g=; b=cuqSXYsKnHhpb7ZJxDyNoKel9Q Z3gcs3PLBiQuVuRPaDl5romKf05sk2Wx6GYR2HcOWW5EjR7eYEKhXIjRL9y83P1ZyKpDhLhnZSsIu ue3l2pVJMKYuGlTScbmASXAz/ntXcATkImoVO8EX2NvyY24zAzdLhSHyc2CC8qgXSOPHIo0K1MOJx k+fOuikdwTdl83Z7eLxxkWRk30HStQuqhiu0AZwrrVDtTkuoXxzlH8bO0v1yBNs07ARI4/H4uplag Z2aUFnaGuZLoH+6ujGR0n2f7QGYVMkYhLkU2OhgKitRJ/5/8WqdZaJQY+40lbfjZc6rEkmQpapAv6 JFNB/c7w==; Received: from authenticated user by zero.zsh.org with local id 1ntmiZ-0000sv-4e; Wed, 25 May 2022 08:50:11 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:33514) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1ntmhm-0000AN-Gw; Wed, 25 May 2022 08:49:23 +0000 Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128]) by joooj.vinc17.net (Postfix) with ESMTPSA id E150E7B; Wed, 25 May 2022 10:49:20 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id AE48D2800226; Wed, 25 May 2022 10:49:20 +0200 (CEST) Date: Wed, 25 May 2022 10:49:20 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: prevent some lines directly coming from the history from being executed Message-ID: <20220525084920.GB97860@zira.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <20220524154738.GA35284@cventin.lip.ens-lyon.fr> <20220525025403.GA97860@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.2.5+22 (1066be97) vl-138565 (2022-05-21) X-Seq: 27800 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 2022-05-24 20:59:53 -0700, Bart Schaefer wrote: > zle-line-finish() { > if [[ $BUFFER = ${history[$HISTNO]} ]]; then > local confirm > read -q confirm"?Confirm: $BUFFER ?" > [[ $confirm = y ]] || BUFFER="" > fi > } There are some display issues in some cases due to the "Confirm"... Instead, if the condition is met, is it possible to remain in ZLE with the current buffer, as if I didn't do accept-line? (I could set a psvar element so that I could change the prompt to indicate that this needs confirmation.) Or perhaps I could change the bindings to use a wrapper around accept-line (ditto for accept-line-and-down-history). Something like that (to be completed with pattern matching): zle -A accept-line real-accept-line accept-line-wrapper() { if [[ -z $psvar[3] && $BUFFER = ${history[$HISTNO]} ]]; then psvar[3]="[Confirm]" zle reset-prompt else psvar[3]="" zle real-accept-line fi } zle -N accept-line accept-line-wrapper where $PS1 contains "%3v", and with psvar[3]="" in precmd(). Could there be any issue? Or is there anything to add? -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)