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

Re: Word breaks around aliased tokens (was Re: PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working))



Bart Schaefer wrote on Wed, Mar 25, 2015 at 20:43:05 -0700:
> torch% alias -g '&&'=AND 
> torch% echo foo&&bar    

I suppose there's a project idea here: implement lisp macros for zsh.

That is, have some hook (maybe preexec or precmd?) get as argument
a list of tokens, and have it return an alternative list of tokens to be
executed further.

Then the && idea could be implemented as:

prefoo() {
  if (( $#reply )) && [[ $reply[1] == '&&' ]]; then
    reply=( ';' '()' '{' 'return' '$?' '}' $reply )
  fi
}

Daniel



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