What makes an alias global? Well, the
-g flag of course. And what does this globality give you? Well, the ability to invoke an alias anywhere in the command line.
If I like the word ‘Potateos’ but I don’t ever have the energy to type the whole thing then I can create a global alias for that word:
> alias -g PO="Potatoes" > echo PO Potatoes
That’s convenient and cool. What is it actually for? Maybe redirecting errors to
> alias -g NO='2> /dev/null' > echo foo >> /dev/stderr foo > (echo foo >> /dev/stderr) NO # no output, it got swallowed!
Looks weird and maybe not useful, but maybe you can creatively find a useful way to use it:
I learned about this zsh functionality and other functionality here.Tweet