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 17041 invoked from network); 20 May 2020 04:16:51 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 20 May 2020 04:16:51 -0000 Received: (qmail 12196 invoked by alias); 20 May 2020 04:16:42 -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: 45863 Received: (qmail 29939 invoked by uid 1010); 20 May 2020 04:16:42 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot1-f49.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.210.49):SA:0(-1.9/5.0):. Processed in 2.888579 secs); 20 May 2020 04:16:42 -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.210.49 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=CDkry8qCc5C4Rin2k1CAUoywj0xFDwSMWvayFeYScJA=; b=jC3FGlSLAdwdzSGjh+ig57DPe2kudDj5w3/NdThgbUUbrGRTNN9oBieFrOIjmjoAZT bg8OC005Q6Zd4xuMDFUxXIUgZ7VUDAEm5QmS4O9oEFzlLukVZ0QrC/RnOf3/b/Oj5b3G 99rgGGEq+CjptaJFrYcxgLIm6Dr9kEhyMbmuMZ8IFSRMBRdY6LxwqurrsRUWOgh8nqgi +YcZ+w2M1PFw00+wWRXJOuLglBoz1YhIvKNAuy/M2rEtBGrqC/PITCnWLWLc110gWsOT bg9pitzsQEJveHKdfOX3ELQzyqp9sdPq++XcrIHkxRquZabtO9V1fZj46Fc4RYvmcaFA VerA== X-Gm-Message-State: AOAM533LgkvBbtm43Bfmvk0zNzLtmxRdw1lZhypekeauh7k9P+oA3hgS aJ0MX6ijQQ8LhVFw3U8NRJF+gAtT8qdK4+4zivv1FA== X-Google-Smtp-Source: ABdhPJz9gTD9/tUEcazHveRUrUohaeK7VHc9tAtx0M0/iI1DfxWEW6FUqAwH/Vh+MPrAkdi5Bq4MsMd+2s9GNns3i5c= X-Received: by 2002:a9d:7e8e:: with SMTP id m14mr1903932otp.229.1589948166065; Tue, 19 May 2020 21:16:06 -0700 (PDT) MIME-Version: 1.0 References: <48e95c73-3a98-a4c2-7e0c-badf8544b4f2@gmx.net> In-Reply-To: From: Bart Schaefer Date: Tue, 19 May 2020 21:15:55 -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 Tue, May 19, 2020 at 5:27 PM Markus N=C3=A4her w= rote: > > On 20.05.20 00:33, Bart Schaefer wrote: > > > > So you can simulate bash's "history -c" by "fc -P;fc -p", with some > > appropriate extra arguments to manipulate history sizes and file > > locations. > > I would not call any of these concepts superior to the other. Different > people just prefer different things. As you like. I just think it's easier to create multiple independent saved histories with "fc -p" than with "history -c" plus modifying a bunch of global variables. > I've read about the push/pop feature, but I'm more the "throw away the > old stuff and start over" kind of guy. I'll never need to pop. :-) You'd pop just to keep the shell from continually consuming more memory. Truly clearing the history is pop followed by push; pushing is just hiding the old history. > Can you give me some advice about the "appropriate extra arguments" you > wrote about ? My goal is to really start over, having nothing left from > the previous history. I don't know your exact use pattern, but let's say for the sake of example that you have 100 commands in your never-overwritten ~/.histfile, but you never want to save more than 20 commands in a given per-project history file. On entering the shell, your 100 saved commands get loaded in. Now you're entering your project, which has its history in $PWD/.project_history (for example). If for example upon "cd" into the project directory, you run fc -p $PWD/.project_history 20 20 that will load the .project_history file and automatically set the HISTFILE, HISTSIZE, and SAVEHIST variables so that when you next execute "fc -P" (presumably, when leaving the directory again) it will save the most recent 20 commands back to the .project_history file, reset the history to those original 100 commands, and restore the old values of the variables. You can modify this behavior by passing only the file name, or the file name and one number, or none of those. On Tue, May 19, 2020 at 5:29 PM Markus N=C3=A4her w= rote: > > I'm currently experimenting with zsh, and I copied my ~/.bash_history to > ~/.histfile. At least, zsh can read the history in plaintext. Careful with that, too. Bash stores its history file as essentially a shell script, and loads it by parsing it as script input but skipping execution. Zsh stores its history file more like text intended to be consumed by the "read" builtin, and loads it straight back into the internal history structure without passing it through the shell language parser. That means that multi-line commands in the bash history will become multiple, separately-numbered events in the zsh history. If all your curated events are one-liners, this won't matter.