Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Global Aliases, but as a function?
- X-seq: zsh-users 27420
- From: Zach Riggle <zachriggle@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Global Aliases, but as a function?
- Date: Sat, 18 Dec 2021 04:38:22 -0600
- Archived-at: <https://zsh.org/users/27420>
- List-id: <zsh-users.zsh.org>
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