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

Re: tab completion in an alias



On Tue, 23 Feb 2010 21:21:36 -0800
John Magolske <listmail@xxxxxxx> wrote:
>     alias d='cd -	'
> 
> So that I could type d, then the enter key, and be presented with the
> directory stack as a menu to scroll down through. Is there some way to
> accomplish this?

The following seemed to work (4.3.10)...


zle-line-init() {
  if [[ -n $ZLE_PUSH_STRING ]]; then
    zle -U "$ZLE_PUSH_STRING"
    unset ZLE_PUSH_STRING
  fi
}
zle -N zle-line-init
alias d="ZLE_PUSH_STRING=\$'cd -\\C-i'"


This causes it to preload the string into the line editor as a string of
characters at the start.  They have to be raw characters to make the tab
active; that's the simplest way I found of doing it.  There are no doubt
entirely different ways of geting a similar effect.

-- 
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