Exercise a lot (and get sunlight exposure) during the day.
Also, never watch movies, read, scroll on a phone, etc in bed. You want your brain to 100% associate being in the bed with sleeping, as soon as it happens
I'm usually out within 5-10 minutes now, since starting to follow those two things reliably
(edit: also, minimizing light exposure in the last couple of hours of your day is good)
edit 2: Forgot the most important thing of all, which is to keep a consistent sleep / wake time every day. Getting rid of all alcohol is great too, if you want actually-decent sleep
Kitty, but most commands are probably happening in eshell. Feels more easily scriptable to me