If you are distracted by a desire to do something unhealthy, shift that focus towards a positive activity. For instance, take a walk outside or even around the room. If you have more time, engage yourself in another activity. You could start cooking, watch a movie, or call a friend.

Once this become routine, you’ll be able to replace your urges with postive activites with little effort. Shifting your focus to another activity will help pull your attention away from the urge that is distracting you. 

Regular exercise may help you avoid distractions, too. Working out releases endorphins into the blood that makes you feel good, which can help you maintain your attention on positive activities.