Global Alias in Zshrc File

I am using the command line in a MacBookPro terminal, with zsh as the default profile.

I am trying to write a global alias to the zshrc in my home directory file but encounter a strange error.

If I write the alias text using NANO the file saves the new alias, however if I write the following in the command line, the zshrc file does not updates to include the new alias.

MWE:

alias -g c="clear"
source ~/.zshrc

Any ideas on how to discover the problem?

1 Answer

Global aliases in Zsh are so aggressive that you’re replacing even the c in ~/.zshrc. Your

source ~/.zshrc

is interpreted as

source ~/.zshrclear

You probably want a simple alias instead of a global alias. Try this instead:

alias c='clear'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest