How to curb a bad nail biting habit?

I have a very bad nervous habit of biting my nails. I’m surprised they haven’t gotten infected, but the skin around them is messed up from years of biting them.
How to curb a bad nail biting habit?
Post Opinion