I never really learned the habit of doing this until very recently and found that it actually took some thought and experimentation to do it well. My fiancee and I reenacted a typical scenario you might get on the street. Saying hi to a person of the sex to which you're inclined can be especially fraught, so we took the liberty of adding a few extra steps on what not to do.
Step 1: Be aware of your surroundings
So the first step is simply remembering to look up and around. Stop staring at the sidewalk. When you do that, you'll become aware of the people you'll soon be passing. The other part of this step is to generally direct your field of vision in the direction of people passing.