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.0 required=5.0 tests=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 58792f03 for ; Fri, 6 Mar 2020 21:16:08 +0000 (UTC) Received: (qmail 3386 invoked by alias); 6 Mar 2020 21:15:59 -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: 24718 Received: (qmail 27716 invoked by uid 1010); 6 Mar 2020 21:15:59 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f171.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25738. spamassassin: 3.4.2. Clear:RC:0(209.85.208.171):SA:0(-1.9/5.0):. Processed in 2.14512 secs); 06 Mar 2020 21:15:59 -0000 X-Envelope-From: schaefer@brasslantern.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.208.171 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uz/63otm49eNQrAb6GP0qlwqxYqg3WDMza6AiL8Lzik=; b=J9vRooYxh5HLx56vyLNZfrRcaQMPfSbbdqClJDgczralXpsFUWAcKc0mXMf9RO9d6e f4vesMr6pOHEM4nablFQTbsyl1TcUpYsZ1GLuGAeA4k9RQrtqHToj1sCORsaEZGbYStb zmV8Sgwol9GaqW5s0RZxzxXGfgrodro1I6SqPPmjlJDes1myxZbpHYbBjLugnf/QUPiR MMgooX8viy9u+P8UeYXfKFk65FQQSYZxxZxN6UZiQrVBVsNA+ynGyLOgIkoLC/w3yLHc jiC3ReLhXFrU7g6H+4JP/lJQLgUWDNg7MHHVlPfdxk12yfCpVacLZYpvpt4YR7JjAJYo g4rw== X-Gm-Message-State: ANhLgQ315GFIAUhGLcRMDFvVxNOG0vXeU5SqCAHojnpSxvJSAwhbK8/H +jqLRalcrb4hO1vnEN0hU6X9DIY65ss7L/yjEDSomA== X-Google-Smtp-Source: ADFU+vt/f8Dl9zp4b2IXVi9RZYEfBPGf7yICB2mddvHiw3e3+ZweRNgFVzlIxKBf7GS8QRuOEzGvUPypUpToJnsXZ3c= X-Received: by 2002:a2e:3807:: with SMTP id f7mr3022857lja.103.1583529321894; Fri, 06 Mar 2020 13:15:21 -0800 (PST) MIME-Version: 1.0 References: <20200306205400.58343f26@hogwart> In-Reply-To: <20200306205400.58343f26@hogwart> From: Bart Schaefer Date: Fri, 6 Mar 2020 13:15:10 -0800 Message-ID: Subject: Re: Deleting entries in history To: Manfred Lotz Cc: Zsh-Users List Content-Type: text/plain; charset="UTF-8" On Fri, Mar 6, 2020 at 11:55 AM Manfred Lotz wrote: > > What is the proper way to delete entries in the history? > > Just load the history file in an editor, deleting things and save it? The first thing to note is that when $SAVEHIST is nonzero, zsh will typically update the file when the shell exits, so anything that is in the runtime history of the current shell might reappear even after it is deleted from the file. I say "might" because this is affected by the assorted setopts that control how the history is maintained. The only safe way to directly edit the history is to make sure no other zsh is running that might rewrite it, and then set SAVEHIST=0 in your current shell before doing anything else. Once you are sure you have done that, then it should be OK to use an editor on the history file. Be aware that multi-line events (such as "for" or "while" loops) are stored with lines terminated by backslash, so if you start deleting a line that ends in backslash you need to also delete all the adjacent lines that end in backslash, up to and including the next following line that does NOT end in a backslash. Single-line events never contain a backslash. If you are using any of the setopts that store timestamped history entries, each event will be prefixed by a ":" command that ends at the next ";", with the timestamp between. You should delete these along with the event you want to remove, and avoid altering any that are on other event lines. All that said ... if the events you want to delete can all be matched by some simple patterns, you might want to look into either a zshaddhistory hook function, or a setting of the HISTORY_IGNORE parameter.