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

Global Aliases, but as a function?



I have long made use of Global Aliases such as...

    alias -g H='| head'
    alias -g L='| less'
    alias -g LL='2>&1 | less'
    alias -g LLC='--color=always 2>&1 | less -R'
    alias -g LLT='2>&1 | less +F'
    alias -g NE='2>/dev/null'
    alias -g NUL='1>/dev/null 2>&1'

These are all very useful, but the aliases do not have access to the
original command.

Is there any way to define something similar to a "global alias" but
which can modify the original command?

There's a lot of use-cases for this, but the one that I'm wondering
about specifically is to pass anything with "--help" in the command
line into a pager that does a best-effort colorization IFF the output
is not already colored.

I don't really want to declare "--help" as a global alias, since any
useful command would necessitate a pipe -- and therefore the original
binary would not emit colorized output to begin with.

Anyway, this is a toy idea at 4:00AM and I'm curious if there's
anything that can be done.

Zach Riggle




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