A traditional method of getting rid of bad habits and replacing them with positive habits from the classic Āyurvedic text, Charaka Saṁhitā, Sūtrasthāna chapter 7.
Ucitādahitāddhīmān kramaśō viramēnnaraḥ| hitaṁ kramēṇa sēvēta kramaścātrōpadiśyatē||7.36||
An intelligent person should gradually wean himself away from unwholesome/unhealthy practices (to which he is addicted) and adopt wholesome ones in the proper sequence. The schedule for the same is given below. [7.36]
Prakṣēpāpacayē tābhyāṁ kramaḥ pādāṁśikō bhavēt| ēkāntaraṁ tataścōrdhvaṁ dvyantaraṁ tryantaraṁ tathā||7.37||
On the first day one should give up a quarter of the unwholesome practice (still maintaining three-fourth of it) and correspondingly adopt a quarter of wholesome. On the second day, half of the unwholesome practice should be given up and half of the wholesome one should be adopted; this is to be continued for the third day also. On the fourth day, three-fourth of the unwholesome practice should be given up and three-fourth of the wholesome one should be adopted. This process should be continued on the fifth and sixth day also. The process of giving up of the unwholesome practice and adoption of the wholesome practice is completed fully on the seventh day. [7.37]
Kramēṇāpacitā dōṣāḥ kramēṇōpacitā guṇāḥ| santō yāntyapunarbhāvamaprakampyā bhavanti ca||7.38||
By slowly and gradually giving up unwholesome practices and by increasing the wholesome practices in proper sequence, the unwholesome practices do not reoccur and the wholesome practices are fully adopted. [7.38]