Replace macOS’s sed with GNU’s sed on a mac

If you don’t want to use different syntax on your mac with sed command then it can be easily replaced with GNU sed by installing it via

brew install gnu-sed

This installs the program as gsed which is also not handy if you don’t want to write different scripts for Linux and macOS. If you want to get rid of macOS’s sed then you need to add the following line to your .zshrc file and restart your terminal or source the config:

PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"

This adds gnu programs in front of macOS’s programs and whatever gnu tools you’re installing via brew are then replacing the existing versions.