From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23545 invoked from network); 6 Nov 2003 08:55:15 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 6 Nov 2003 08:55:15 -0000 Received: (qmail 14181 invoked by alias); 6 Nov 2003 08:54:52 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6744 Received: (qmail 14140 invoked from network); 6 Nov 2003 08:54:52 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 6 Nov 2003 08:54:52 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [212.227.126.201] by sunsite.dk (MessageWall 1.0.8) with SMTP; 6 Nov 2003 8:54:52 -0000 Received: from [172.17.36.7] (helo=erdbeere.use.schlund.de) by mxintern.kundenserver.de with esmtp (Exim 3.35 #1) id 1AHful-0004AR-00 for zsh-users@sunsite.dk; Thu, 06 Nov 2003 09:54:51 +0100 Received: from luthien by erdbeere.use.schlund.de with local id 1AHful-0007ye-00 for ; Thu, 06 Nov 2003 09:54:51 +0100 Date: Thu, 6 Nov 2003 09:54:51 +0100 From: Dominik Vogt To: Zsh Users Subject: skipping duplicates in some zle functions Message-ID: <20031106085451.GD28005@gmx.de> Reply-To: zsh-users@sunsite.dk Mail-Followup-To: Zsh Users Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i I'm already using a fairly complicated function bound to Up and Down that combines up/down-line-or-search and history-beginning-search-forward/backward (see below). I want to enhance it so that it skips lines that are identical to the line that is currently displayed. E.g. If I have the following lines in the history (latest one at the bottom): ls /tmp cd /tmp ls foo* rm foo rm foobar ls foo* cd Now I type $ ls f ^ |___ cursor and get $ ls foo* ^ |___ cursor Now I press again, and with the current functions, the second "ls foo*" entry is selected. But I'd rather skip that one and proceed to "ls /tmp" immediately. Any hints how to do this? ------------------------------- snip ---------------------------- function __up_or_down_line_or_beginning_search { if [[ $LASTWIDGET != down-line-or-beginning-search && $LASTWIDGET != up-line-or-beginning-search ]]; then local LBUFFER_STRIPPED="${LBUFFER/#[ ]#/}" if [[ $RBUFFER == *$'\n'* || ${LBUFFER_STRIPPED} == "" ]]; then __last_up_line=up-line-or-history __last_down_line=down-line-or-history else LBUFFER_STRIPPED="${LBUFFER_STRIPPED/#[^ ]#[ ]#/}" if [[ "$LBUFFER_STRIPPED" == "" ]]; then __last_up_line=up-line-or-search __last_down_line=down-line-or-search else __last_up_line=history-beginning-search-backward __last_down_line=history-beginning-search-forward fi fi fi } zle -N __up_or_down_line_or_beginning_search function up-line-or-beginning-search { __up_or_down_line_or_beginning_search zle .${__last_up_line:-beep} } zle -N up-line-or-beginning-search function down-line-or-beginning-search { __up_or_down_line_or_beginning_search zle .${__last_down_line:-beep} } zle -N down-line-or-beginning-search bindkey "\e[A" up-line-or-beginning-search # Cursor up bindkey "\e[B" down-line-or-beginning-search # Cursor down ------------------------------- snip ---------------------------- Ciao Dominik ^_^ ^_^