I can't imagine this is a very common occurrence, but I'm writing this anyway: how to write a thesis with a newborn.
1. Give yourself a maternity leave. You need time to settle in to being a new mom. If you don't block out time to do so, you will end up feeling guilty or anxious about not working on your thesis. I took two weeks off, which was enough time to catch my breath but not so long that I lost my momentum.
2. Set up your work space in a convenient area. Every morning, I brought my computer and research materials downstairs to the kitchen table so I could sneak over and get some work in during any spare moment. It was also easier that way for me to keep an eye on baby as I worked. If the computer is allllll the way upstairs in some cozy den with a door that shuts, well, you may never touch the computer during the course of the day.
3. Figure out your baby's fussy patterns and schedule your prime writing time accordingly. A colleague of mine used to stay up most of the night working on papers while her newborn slept. For me, mid-morning into early afternoon was the sweet spot.
4. Schedule a quitting time, too. No matter how much or how little progress I had made on the thesis, by the time the girls came home from school at 2.45p, I called it a day. I knew I would only frustrate them, the baby, and myself by trying to get meaningful work done in the presence of three needy children.
5. Work every moment you can. If you wait for the stars to align just so - baby's sleeping, mama's fed, house is tidy, thought processes are clear - you will never type a word. It was hard for me to get in the writing groove when I was not feeling it AT ALL, but I trained myself to be able to work in whatever small increments of peace I could get. Pre-baby, I would wait for large blocks of time to get real work done, but that system did not work with a newborn. PS: you will not get any naps.
6. Do it NOW. You might be tempted to think, "oh, I'll wait until baby's a little older. It will be easier then." Wrong. It will be easier now. Newborns are sleepy and don't need much intensive one-on-one interaction. Therefore, you can put the baby in a wrap or sling or near you in a bassinet and s/he will be happy and calmed with no need for endless games of peekaboo. Sterling is four months old now and writing a thesis at this point would be much, much harder than it was two months ago.
And that's how you write a thesis with a newborn.