The worst thing I can do at the beginning of a programming session is to close all my tabs.
It's a guarantee that I'm not about to start coding. When closing tabs I'm sure to find something that I should just "read right now and get out of the way". All of the sudden I've read several posts and my brain has been primed to seek novelty.
Not the state of flow I was looking for.
Luckily, this isn't my first rodeo. Here are a few off-the-beaten-path suggestions for getting in the programming zone:
Minimize all the windows you don't need
The digital equivalent of pushing everything on your desk to the ground.
Don't even look at what it is, just minimize it all.
Open new windows, start new terminal sessions. Give yourself the blank slate you would ideally have started with. With any luck your computer will crash at some point and you'll never have to face that mountain of blog posts.
A clear workspace is important for focus, this is the most efficient way to get there.
Listen to the same song on repeat
I'm sure this one makes me seem like a real psycho.
Choose a long song with no lyrics and set it to repeat. Classical or jazz works great. Time will fade into the background and distractions will disappear. If you notice the song starting over, turn on cross-fade so that it is seamless.
Focus happens when there is just enough going on to distract you from boredom, but not enough to overwhelm you.
When all else fails, pair up
Like it or not, focus has an emotional component.
When there is something bothering me, concentration becomes difficult. Usually getting out for a walk is the remedy, but when that fails I put out the bat signal for a pair programming session.
Pairing forces you to focus using social pressure. Plus, it's a great way to deepen relationships and be productive.
These are some of the weird ways I get myself to focus on doing what I love: programming. Let me know your tricks so I can add them to my toolbox!