From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4274 invoked from network); 18 Oct 2000 00:31:34 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Oct 2000 00:31:34 -0000 Received: (qmail 1181 invoked by alias); 18 Oct 2000 00:31:20 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3458 Received: (qmail 1170 invoked from network); 18 Oct 2000 00:31:19 -0000 Date: Tue, 17 Oct 2000 20:31:23 -0400 Message-Id: <200010180031.UAA21435@soup.ql.org> X-Authentication-Warning: soup.ql.org: ejb set sender to ejb@ql.org using -f From: "E. Jay Berkenbilt" To: zsh-users@sunsite.auc.dk Subject: more tcsh-like history-search capability Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII By default, zsh's history-search functions look through history for lines whose first word starts with the first word on the command line. I prefer to search for commands that start with the string before the cursor. After snarfing Bart's code to handle the literal history stuff (zsh-workers/10996), it occurred to me that I could solve my history search problem with zle widgets as well. This was one of the (many) areas of zsh that I had not explored at all. Here are my trivial zle widgets that implement history searching the way I want it. I don't have a good name for these widgets... the q- here is the same as the q in ql.org -- my favorite letter. (Some people don't outgrow their favorite letters. :-]) It makes me happy to be using a shell that can be customized like this. :-) --------------------------------------------------------------------------- q-history-search-backward() { local cursor=$CURSOR zle .history-search-backward "$LBUFFER" CURSOR=$cursor } q-history-search-forward() { local cursor=$CURSOR zle .history-search-forward "$LBUFFER" CURSOR=$cursor } zle -N q-history-search-backward zle -N q-history-search-forward bindkey "^[p" q-history-search-backward bindkey "^[n" q-history-search-forward --------------------------------------------------------------------------- -- E. Jay Berkenbilt (ejb@ql.org) | http://www.ql.org/q/