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.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,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 E63F625470 for ; Sun, 11 Feb 2024 02:28:52 +0100 (CET) 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:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=WBpzweH+PBJsbqYBL9a+lOqc5gRLm78N98NPbjp393I=; b=C0Qpk6oH9LeGriT9hXqSgw0E7G SeQjVaCG0I25wRw+dkEZfFKdlx4wjww/uB3sGlayusG/ZsvMvfERjzgXe6rYtZPCt3UII9ZrLoz5g VI8a/82h0Wz5WH8zD6MsugnYKrjltrS2WMy9Tqaw+8DmjO5GVbRgyMUkPSreHSDOm80vd4t8VHRX8 2pZ+xjGiJoGUdegP5OXwFTNc9gw2nXUpVEH6jBEk7/WlKy2yK1vj0kSNduUzaR5hnVcGQJQDZn4Za 1GP1M+ZlMjsVQmfXKba24nTNgNvkKXzrZbqHveOH18rSinko7842X/xlq1Elc/5BH4zzV2JcKZJ+f gfNoGQ+A==; Received: by zero.zsh.org with local id 1rYyeK-000LWo-El; Sun, 11 Feb 2024 01:28:52 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rYydp-000KrU-Iy; Sun, 11 Feb 2024 01:28:21 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 62CCE27C005B; Sat, 10 Feb 2024 20:28:19 -0500 (EST) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Sat, 10 Feb 2024 20:28:19 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtgdefiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpefnrgif rhgvnhgtvgcugggvlhojiihquhgviicuoehlrghrrhihvhesiihshhdrohhrgheqnecugg ftrfgrthhtvghrnhepteevfeekffelfeduiedvkeejhfeiiedvgeegfeefheffteeluedv ledthfejudefnecuffhomhgrihhnpehsthgrtghkvgigtghhrghnghgvrdgtohhmnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihv odhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduud elvdejfeekhedqlhgrrhhrhihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 2C09031A0065; Sat, 10 Feb 2024 20:28:19 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-144-ge5821d614e-fm-20240125.002-ge5821d61 MIME-Version: 1.0 Message-Id: In-Reply-To: References: Date: Sat, 10 Feb 2024 20:27:04 -0500 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: zsh-users@zsh.org Cc: "Max Blue" Subject: Re: About de-duplicating the history and history appending Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 29651 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: I participated in the aforementioned IRC discussion. Here is some additional information for anyone inclined to chime in: On Sat, Feb 10, 2024, at 6:00 PM, Max Blue wrote: > Hello. > > I have been trying to mix the features which allows me to de-duplicate=20 > and avoid excessive lines in my history, with the 'appendhistory'=20 > variable, which somehow seems to be incompatible. > > > > I wanted to remove all the duplicated entries after the terminal=20 > closed, so it would be far easier to search and also to keep at hand=20 > 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. > After a lot of help from the people in #zsh , i encountered a way to d= o=20 > this, 'externally', with a script. > > > > In my .zshrc i have added a 'trap my_script.sh EXIT' trap, which makes=20 > the script to be ran after i close the terminal. > > > > The script in question has the following inside: > > ---- > > *#!/usr/bin/env bash > > #tac ~/.bash_history | awk '!x[$0]++' | tac > .bash_h && mv .bash_h=20 > .bash_history *-->* *This one saves the last occurence of the repeated=20 > lines(commented)* > > awk '!x[$0]++' ~/.bash_history > .bash_h && mv .bash_h .bash_history = =20 > * -->* *this is what i am using at the moment. > > ---- This was adapted from . > So, with the default values for *share_history *and *appendhistory,=20 > *and the following line also inside .zshrc: > > *setopt HIST_IGNORE_ALL_DUPS HIST_IGNORE_ALL_DUPS HIST_IGNORE_DUPS=20 > HIST_SAVE_NO_DUPS HIST_FIND_NO_DUPS* > > I have it working. > > But an user of the #zsh channel told me that this kind of script would=20 > break multi-line lines saved in the history, and i also have noticed=20 > that after running this script, some special characters becomes 'weird= '=20 > into the *.bash_history *viewing. With weird i mean things like *=C3=AF= =C2=BC=C6=92=C2=BA=20 > *and* =C3=AF=C2=BC=C6=92=C2=BA *,which fortunately are not present in = the terminal history=20 > (the commands are properly shown in there). 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. > Is there some way to improve this? to make it to not break multi-line=20 > history entries, to remove the 'weird characters' from the text file=20 > and also to know if this would break my history in a random moment. > > > > This is my first message in here so i do not know if the order of=20 > exposing it was the correct. > > > > Bluey --=20 vq