Home > database >  How do I set an entry to PATH in .zshrc based on the user's CPU architecture?
How do I set an entry to PATH in .zshrc based on the user's CPU architecture?

Time:09-08

My colleagues and I use the same .zshrc file. We would like it to automatically set an entry to PATH if the user has an M1 macbook which has a different way of installing a package (ansible in this case) compared to Intel based macs.

If user has an M1 macbook this should be added to PATH:

$HOME/Library/Python/3.8/bin

How do I go about doing that?

I was thinking about using uname -p to output processor architecture and then make a conditional within .zshrc but I'm not sure where to start. For instance I don't know if it's possible to add an entry to an already existing PATH.

CodePudding user response:

if [[ $(arch) = arm64 ]]; then
  PATH =:$HOME/Library/Python/3.8/bin
fi
  • Related