zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Matthias Kopfermann <matthias@kopfermann.org>
Cc: zsh-users@sunsite.dk
Subject: Re: menuselect and history
Date: Mon, 19 Apr 2004 09:23:41 -0700	[thread overview]
Message-ID: <040419092341.ZM10180@candle.brasslantern.com> (raw)
In-Reply-To: <20040419095235.GA1285@kopfermann.org>

On Apr 19, 11:52am, Matthias Kopfermann wrote:
> 
> i just wondered whether it wouldn't be very cool if menuselect was
> useable with historylines.

--- 8< --- snip --- 8< ---
#compdef -k menu-select ^X:

# _history_select -- create a menu-selection of the command history

# Works only if invoked on the command word (( CURRENT == 1 )).
# Requires 4.2.0 or a recent 4.1.x for the 'n' parameter flag and
# array+=string assignments.
# BUGS:
#	This doesn't really scroll through the history, it scrolls
#	through commands in the history and re-inserts one as the
#	current history line.  So accept-line-and-down-history will
#	not work as expected, but accept-and-infer-next-history is
#	probably OK.
# TODO:
#	special case for (( HISTSIZE > 9999 ))
#	zstyle for how much of the history to include
#	use the numeric prefix to set the starting point?

emulate -L zsh
zmodload -i zsh/parameter || return 1
(( CURRENT == 1 )) || return 1

local h c
local -a histnos commands displays
histnos=(${(Onk)history})

for h in $histnos
do
  c=$history[$h]
  commands+=$c

  # Various display bugs require that we trim each selection to fit on
  # a single line.  Use a display that includes the history number.
  if [[ $#c -gt 71 ]]; then c[72,-1]=...; fi
  c=${c//$'\n'*/ ...}
  displays+=${(r:5:)${(l:4:)h}}$c
done

compadd -Q -l -V commands -d displays -a commands
--- 8< --- snip --- 8< ---


       reply	other threads:[~2004-04-19 16:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040419095235.GA1285@kopfermann.org>
2004-04-19 16:23 ` Bart Schaefer [this message]
2004-04-20 16:08   ` Felix Rosencrantz
2004-04-22  4:57     ` Bart Schaefer
2004-04-23  6:56       ` Felix Rosencrantz
2004-04-23 16:18         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=040419092341.ZM10180@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=matthias@kopfermann.org \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).