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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like