Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

run-help as a widget



On Mon,  7 Dec 2009 01:57:10 +0100
JÃrg Sommer <joerg@xxxxxxxxxxxx> wrote:
> I know, this solution is a dirty hack, but it's quick. The better way is
> to fix zsh to call run-help with the whole commandline where the alias
> gets expanded and this commandline gets passed to the second run-help
> call.

I've been using this for a while, it's perhaps time something along these
lines got included in Functions/Zle.  I was a bit surprised to find I
hadn't.

With this it would be worth upgrading run-help and helpers to check if
there's already a full command line there, and to advance past precommand
modifiers.  I thought I'd done some of this, too, but maybe not...
I might simply have been thinking of expansion of aliases.

By the way, note this quotes all buffer words:

  ls foo; rm -rf ~<Esc>h

is safe even if it may not do quite what you actually want, which is quite
hard to guess.  (But I didn't try it quite like that anyway...)


# run-help-widget
#
# This is a widget to replace the builtin widget run-help.
# It passes the entire command line to run-help.  This is often
# more useful.
#
# Typical usage:
#   zle -N run-help run-help-widget

local -a line

if is-at-least 4.3.10; then
  line=(${(q-)${(z)BUFFER}})
else
  line=(${(qq)${(z)BUFFER}})
fi
zle push-line
BUFFER="run-help ${line}"
zle accept-line


-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



Messages sorted by: Reverse Date, Date, Thread, Author