Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIFF9-007GeT-PR for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Dec 2023 21:45:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rIFF7-00G2fO-6q for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Dec 2023 21:45:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIFF6-00G2fF-FT for pgsql-hackers@lists.postgresql.org; Tue, 26 Dec 2023 21:45:40 +0000 Received: from relay1-d.mail.gandi.net ([2001:4b98:dc4:8::221]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIFF3-00CLDe-Ca for pgsql-hackers@postgresql.org; Tue, 26 Dec 2023 21:45:39 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 6F36E240002; Tue, 26 Dec 2023 21:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postgresfriends.org; s=gm1; t=1703627132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vQu6t3B8JH6/YTzYqguYIC55MHbylokYdqThlU1hYws=; b=O1pyfCy2TNOhNmev7cvo2ivuZEgTPp0ln7h9B363fbuoUk3Laayo901WujXfYzv40iZxY5 Q4TDeFoUdRSVnAMO7FmHCMmpjgU8iUUmTZSl6YIOTywbudNLnEsa345ZTCoExIpGLrNEb+ lJ4dHQjBD8f7i5IPVFSY0sWP6nY5ABgnzhzpqmtJXLoBnTtluJdWPbGKmK6zfy+fCLyi0n x1/4AkN4cjAAIzlrwgxbraUVK8WbEXZs9dFS7GLZzTivh3TI/APVLahvWTV2S9QkRGf2/s hkCOeo4FThcazHIhzjQpBAIHVSkmSemM43jMCVOyuhxJjRmqdjOMc4YTq83aLg== Message-ID: Date: Tue, 26 Dec 2023 22:45:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: A tiny improvement of psql To: Tom Lane , Kevin Wang Cc: pgsql-hackers@postgresql.org References: <2036813.1703608601@sss.pgh.pa.us> Content-Language: en-US From: Vik Fearing In-Reply-To: <2036813.1703608601@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: vik@postgresfriends.org List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/26/23 17:36, Tom Lane wrote: > Kevin Wang writes: >> As you know, we can use the UP arrow key to get the previous command to >> avoid extra typing. This is a wonderful feature to save the lives of every >> DBA. However, if I type the commands like this sequence: A, B, B, B, B, B, >> B, as you can see, B is the last command I execute. > >> But if I try to get command A, I have to press the UP key 7 times. I think >> the best way is: when you press the UP key, plsql should show the command >> that is different from the previous command, so the recall sequence should >> be B -> A, not B -> B -> ... -> A. Then I only press the UP key 2 times to >> get command A. > > This is driven by libreadline, not anything we control. I have > seen the behavior you describe in some other programs, so I wonder > whether it's configurable. It is kind of something we control. Per the psql docs, setting HISTCONTROL=ignoredups will do the trick. https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-VARIABLES-HISTCONTROL -- Vik Fearing