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

Re: default pipe



On Jul 25,  4:57pm, GoTaR wrote:
}
} Is it possible somehow to set default pipe command?

Well, it's possible *somehow* but ...

} $ ls | <enter>

This is syntactically incomplete, so zsh is going to print the PS2
prompt and wait for you to enter another command.  In most cases I
think this is what you'd want.

The only way to subvert this is to hack the accept-line ZLE widget:

function accept-pipe-as-terminator {
   setopt localoptions extendedglob
   if [[ "$BUFFER" = *\|[[:space:]]# ]]
   then
      # in 4.2.x and later, use BUFFER+=less
      BUFFER="$BUFFER less"
   fi
   zle .accept-line
}
zle -N accept-line accept-pipe-as-terminator



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