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=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15220 invoked from network); 21 May 2020 01:06:22 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 21 May 2020 01:06:22 -0000 Received: (qmail 2833 invoked by alias); 21 May 2020 01:06:12 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45871 Received: (qmail 20332 invoked by uid 1010); 21 May 2020 01:06:12 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi1-f181.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25814. spamassassin: 3.4.4. Clear:RC:0(209.85.167.181):SA:0(-1.9/5.0):. Processed in 4.918063 secs); 21 May 2020 01:06:12 -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.167.181 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:content-transfer-encoding; bh=IcOEOaZgFmqADsyM992v7HwneLr9SApoDJ2gYoNDmQw=; b=dohZLAcjJeihr+36hlxmzypapIV/u3EvNylx2jphuV7+YVG+8/sq4Gjiy36GViKs0f BTQ6gYIa/oQKCOAH3bzRnU0bS0KOOsuVyZxm26bTP6NNrfXDOssaHFdt+2pH6vF8l2MG 0NPlSnsIwgE0gBt6l5cEIXpJVb/v7icUxjpTaMXSK3DYwhp+4U9UlkghtgKTnBzkRwwL Scuo+ZdvSTzP+mTYK/z38+SeGxuLdKrcZGqbgc1/0oafwzzts4k1gJhuA2rCwp6VvlSp biKLocGqIFA0nuWBg1PYLsWVaIKsVX2GAPBz24X++1dccgeGfz05cKEGp1TC4VM7+07W mJ9g== X-Gm-Message-State: AOAM531DaOhlFkdAKaYWDbMAT95Y51ese10kntw9PtHTy0DH7NvaxFh/ GJkoYQfG9heQSo+/O0PsPqRTstoZe1Yj8db16o27SQ== X-Google-Smtp-Source: ABdhPJwi6tpVEI5mDeOh3KUr1IPujCkpuPKNrHwr0Iz8YDFTHjO6TBHUvha3DqWJBb/DRXK8JSCPwmRUQiBLeOgVUG0= X-Received: by 2002:a54:468e:: with SMTP id k14mr5301327oic.132.1590023134357; Wed, 20 May 2020 18:05:34 -0700 (PDT) MIME-Version: 1.0 References: <48e95c73-3a98-a4c2-7e0c-badf8544b4f2@gmx.net> <2ca16a5c-a1e9-904d-f3f6-bf785ab00343@gmx.net> In-Reply-To: <2ca16a5c-a1e9-904d-f3f6-bf785ab00343@gmx.net> From: Bart Schaefer Date: Wed, 20 May 2020 18:05:23 -0700 Message-ID: Subject: Re: Feature Request: fc -C to clear history and reset counter To: =?UTF-8?Q?Markus_N=C3=A4her?= Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 20, 2020 at 2:39 AM Markus N=C3=A4her w= rote: > > Keeping the shell from continually consuming more memory is one of the > reasons why I hesitate to use push when I know I never will pop. It's harmless to pop when nothing has been pushed, so you can just do history_c() { fc -P ; fc -p } Then stick that in your current bash usage pattern wherever you have "history -c" and go on your merry way. You'll always have exactly one extra "depth" of history. However, there is probably more you can do if you're interested in digging into it. > My usage pattern is even more complex. I's heavily based on making a > difference between the commands loaded from my curated history files and > the "local" or "transient" history while running the shell. I put way > more effort in preparing things, then using them will be easier. The "fc -I" (dash capital eye, for those in sans serif) can be used to select only the commands that were entered interactively, if that is helpful. That is, it excludes any commands read from a history file, whether at startup, or with "fc -R filename" or "fc -p filename". (There is not presently an inverse of this.) > You wrote that pop will save back the project history file. That's also > something I'd like to prevent. This can be done by changing/unsetting HISTFILE, or zeroing SAVEHIST, after "fc -p". > **My curated history files are sacred. No one but me should write them.** Why not keep them "chmod -w" and only make them writable during editing? > All of the entries in my history files start with a blank. So a command > never gets duplicated to the bottom when I recall it, but recalling > works despite the blank. (The igonoredups/ignoreboth in bash seems to > work only on consecutive duplicates). Zsh additionally has histignorealldups, but I don't think it works the way you want. However, you might take a look at the zshaddhistory hook function, and the HISTORY_IGNORE variable. > **I hope this makes clear that history_edit is a completely normal thing > for me to do. Sometimes every few minutes. Having to deal with push/pop > will make this much more complicated as I have to keep track if and how > many times I have pushed.** Does this mean that you are always clearing the history, editing the file, and then reloading from the file? Thus in each of the two or three shells that you start to enter a project, your edit begins from whatever you saved in the previous shell? I was thinking about what Daniel said about using vared on the history, to edit it within the shell rather than in a disk file. There might be a way to simulate that in shell code, using "fc -p" to install the edited events. Hmm.