I've never had a problem with bears in town, but I keep my distance.
Pepper spray was originally invented to repel grizzly bears. I carry that when I hike.
I also have a small device that emits an irritating sound (inaudible to humans) that works well in repelling and quieting dogs. It's called "Dog Off" and is made by Lentek.
When we first moved here in the early 1990s it was a very dry year, and the bears were everywhere. Every trash can left out before trash day was a target. None of them was ever aggressive with a person that I remember, but I do remember a kid carrying his lunch, and a bear relieved him of it.
Our kid has 2 big dogs with her when she's out in the back yard. Usually, you can tell that there's a bear around by the barking dogs. When the barking gets close, be observant.
A young bear also showed up at the sandy end of the Country Club once. Cleared everyone out pretty fast.