zsh-users
 help / color / mirror / code / Atom feed
* Global Aliases, but as a function?
@ 2021-12-18 10:38 Zach Riggle
  2021-12-18 22:40 ` Bart Schaefer
  0 siblings, 1 reply; 10+ messages in thread
From: Zach Riggle @ 2021-12-18 10:38 UTC (permalink / raw)
  To: Zsh Users

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-12-22 20:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18 10:38 Global Aliases, but as a function? Zach Riggle
2021-12-18 22:40 ` Bart Schaefer
2021-12-20 18:42   ` Daniel Shahaf
2021-12-20 20:04     ` Bart Schaefer
2021-12-20 20:11       ` Roman Perepelitsa
2021-12-20 20:24         ` Bart Schaefer
2021-12-21  0:57           ` Zach Riggle
2021-12-21  0:56     ` Zach Riggle
2021-12-21  1:55       ` Bart Schaefer
2021-12-22 20:14         ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).