From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id AD7E621817 for ; Sun, 11 Feb 2024 05:34:02 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707626042; b=HITq+uIXLqljSCmUounWEp5SU6UKP3VA+3lIHmzk625pvGEEFGktW/JgHK08Fg5wbybZz2Vrdt b2c5ds7EOaJ2doB6yXAUzDXdjkChB0ff0ptlfama/TEB/siGw29R4GM+hOvmPw4ZRptUlxmfVF yPmG06Mxhws0l3NHhjQVBoVsnXH05Uj2IEWQlkZLXVkWr4B/Y9ZJDM/W+iLktJP6bv6P9pW8gS cfzOU3V+7fSLfelko8d+qffpe5IDK4As4mu1JmFmbZR1VreltdEgIX4lcIV3OSfROeZWeuQHfO SOqb1q7Dfq24qoN3QdSVJ8Zd5bhOJ5fZURDr1oMgvIZY2A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1707626042; bh=G980g5f+8OU4Ch8MsmrOIYWK6BAkyyO/igxSj0QU6r4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=Ajze5CTFUTWptFv4LBA3gLufWqCsiFNErU0Nf/zK8LPriChp3cmth72neUOuKV8ECMvmy4yKQ7 SvvuNjIgzqe2RumegDawf9AnJz36Z+fuV6gYtW3EYyC9+jsR5IFvZAwr+MN/+ZRyKYOtn8az/P NpkPCxiLBC6fkvGQWdZX4jpS/CMGv7TlxzUZeHfshxoimmEghg07RnzlHOmLZk4vj0tj6an0wp yKVtl2RF2B7fmu3iiFpLaTebnfqmP8wgtIzJWNfZ9zsZFDNW6e4uX7WsPHzL5iM5VT0IP94hPG uJRGMLB9BD3BMVjsLujKDPAgc7A1QqQ74A9t/NhgKforCw==; 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-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=yWUCB3l9yLo2CWL9xe7YmYgd93mqkDwJ06ULIREovVA=; b=sFUgi0k5CxbN94IUPhJO+X3UPs byyjcT+EeVQeNq/GMWPUpLG9/IZqgTsu2KQMyVBefgWGsQmm51S59R5g6h+8uw+7E6OFWKpxGNv9z VDKudPMX2WguwcHaDdH/OMk4U/9UFTv6kHPaSbV6O80Zpq20oXSMRH0tzsL/qMkmtACktkUMvlCpv zIW2UUmtjXe25AKgSSM1QINNX9mmm5+FJmSNbMwR8HI8Nl/wcWftM1OkTv7AYpq7r96KOKHlhOWG7 tEIad8rDHRrJCvv75i+GXurDIs2hsrSp+7X/jRzwzTCOV9utjt8eSkqvVUIwNruArngDLD+SOeDHY tQNDoRng==; Received: by zero.zsh.org with local id 1rZ1XU-0002H3-FX; Sun, 11 Feb 2024 04:34:00 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f51.google.com ([209.85.218.51]:52661) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rZ1Wm-0001aA-Sg; Sun, 11 Feb 2024 04:33:19 +0000 Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a389a3b9601so286773566b.1 for ; Sat, 10 Feb 2024 20:33:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1707625996; x=1708230796; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yWUCB3l9yLo2CWL9xe7YmYgd93mqkDwJ06ULIREovVA=; b=AN3doVfx+snUYd8Tvvo4pFKRmoWM2WQ3HUplRMw590LTEpzySjRxD0fKhUc/oETPBp xUMVIL0ac09+Kj4qAmkfE85dvX6MKDM/mhIzH107c+DqrYizQkkjWN3ggO0eZRZqOSsU v2p7ybf5jFqAZ7+rwU0TYnVbL6x9NjG3w/luvCb0SVHe++7E8cON8Qcfqk/2xSHmHPOr Ys79KlSKpObG+s8AXMldfxJMCaL1eOJe4jG9Trz0b7nm9fvq3bdkSPkHhEMkTbUIof0C T3xqNUTF8S3k0+iWibL46o+sc9UcJHokM6k5kLRsGXDGd2UqLOmZiY3sNCeR5VehSU7U 8+Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707625996; x=1708230796; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yWUCB3l9yLo2CWL9xe7YmYgd93mqkDwJ06ULIREovVA=; b=FwkWpnIRP7ZDbcBEGJj9w5oxmpl/Ngzf3OND3jAlfsI2C7FVhIrJOgZY887fqM0zCE 3fxLGl78Dwo3qQF9U0dscWg+Or40ZqkCa5BGhB8ouTgyPeaDMgYTiEBCOfa8aORPNqKJ cdc9Qhd/M8WSL4fxXTiEBlOpyAvMYvRIgAWKb4tnSr5G6eivj2yfBSal5+wKGRaoHCZ1 uI/oF5WHmoRJErCvDhAY0IZLXJN1ZPfqVXmqnyI2MIYcDC701eeIaCSsRzHOW64Z7vEK MB7qJvjMnOEnsROu/mlelf3+v4OGrAQqh/aAtVgsuaKboRn/FWKc/hW1VZLSBuc4A+c+ YQiQ== X-Gm-Message-State: AOJu0YzKUfl0x6VjkpnnuHqP62ZA5WiDXOgAKT+TsofSr/+7H+olBAMi R/0vH+up/5mW6gWbZafGjhLZVDwtF1zXQHCxPs/jueksG4xsJJm4QNSLtCYCXbnCpB/QFZBaC95 TwDhGoTXErhdyjsKC0bTTBxj1/pWygcwIZjzYttJXBR5ixlbgVQ== X-Google-Smtp-Source: AGHT+IFutS3DhqXbLJ9c1z18weH4UkxapeeRbQ/eLcCfoklj9mqWV7FWcGAyHVyrw52cD4p4GEkIi7y21nXdVDVbNWc= X-Received: by 2002:a17:907:b9c4:b0:a3c:fcd:7768 with SMTP id xa4-20020a170907b9c400b00a3c0fcd7768mr2118266ejc.71.1707625996133; Sat, 10 Feb 2024 20:33:16 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Sat, 10 Feb 2024 22:33:04 -0600 Message-ID: Subject: Re: About de-duplicating the history and history appending To: zsh-users@zsh.org Cc: Max Blue Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29652 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 Sat, Feb 10, 2024 at 7:28=E2=80=AFPM Lawrence Vel=C3=A1zquez wrote: > > On Sat, Feb 10, 2024, at 6:00 PM, Max Blue wrote: > > > > I wanted to remove all the duplicated entries after the terminal > > closed, so it would be far easier to search and also to keep at hand > > the command i use the most. > > To be clear, the goals are: > > - To deduplicate the entire history file every time a shell saves > its history. > - To keep concurrent shells from trampling on each other's divergent > history entries, as is possible without APPEND_HISTORY. [...] > The use of ".bash_history" here is not a mistake. OP really is > trying to use a single history file for both bash and zsh. These are fundamentally incompatible goals. Bash and zsh will not cooperate with each other for purposes of (avoiding) overlapping writes, the timestamp formats are incompatible, and the zsh history is stored "metafied" -- it is not a plain text file. That also explains this: > > that after running this script, some special characters becomes 'weird' > > into the *.bash_history *viewing. With weird i mean things like *=C3=AF= =C2=BC=C6=92=C2=BA > > *and* =C3=AF=C2=BC=C6=92=C2=BA *,which fortunately are not present in t= he terminal history > > (the commands are properly shown in there). Moving along ... > This was adapted from . I'm not going to try to work through all of that ... but I see it does discuss the timestamp problem. > > *setopt HIST_IGNORE_ALL_DUPS HIST_IGNORE_ALL_DUPS HIST_IGNORE_DUPS > > HIST_SAVE_NO_DUPS HIST_FIND_NO_DUPS* I think you mean for one of those to be HIST_EXPIRE_DUPS_FIRST ? My approach to this would be to use "fc -p" to point to a new history file with setopts as appropriate from the above, pull the HISTFILE into that with "fc -R", write it out again with "fc -W", then move that to the desired history file with appropriate locking (which you can probably do by calling "fc -P" to switch back to the original history and then cycling -R/-W again). If you write that as a zsh script you can invoke it from bash to clean up bash's history as well, with the timestamp caveat. I'm not at my usual computer right now so not going to test details, I'll chime in again later if things seem to be going awry.