How to set the fish installed by brew as the default shell

The official setup is

 chsh -s /usr/local/bin/fish

But this is based on the fish installed through the official method, and the path for fish installed via brew is not there, which causes an error

chsh: WARNING: shell '/usr/local/bin/fish' does not exist

Now enter the terminal

brew info fish

to find the installation path of fish

For example, mine is

/opt/homebrew/Cellar/fish/4.0.1

The fish in the bin folder under this path is what we need

/opt/homebrew/Cellar/fish/4.0.1/bin/fish

Now it will work

chsh -s  /opt/homebrew/Cellar/fish/4.0.1/bin/fish