Add function to ~/.zshrc

I'm trying to apply the following :

But I'm stuck/missdo on the part to copy and paste the function cppcompile when I open

sudo code ~/.zshrc

Because after following all the steps when I try to compile my program I got the following :

bash: cppcompile: command not found

So how to add a function to ~/.zshrc? (Personally, I just copy and paste it as it said, or maybe there is a proper way to do it?

1 Answer

.zshrc is executed when you open a new shell. Changes in it don't affect existing shells automatically. So either:

  • Open a new shell, or
  • Use the command . ~/.zshrc (yes, it starts with a dot followed by a space) to execute the file again in your current shell

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