שולחן ערוך אורח חיים הלכות הנהגת אדם בבקר סימן ב סעיף ו
אסור לילך בקומה זקופה, ולא ילך ד' אמות בגילוי הראש (מפני כבוד השכינה), ויבדוק נקביו. הגה: ויכסה כל גופו, ולא ילך יחף . וירגיל עצמו לפנות בוקר וערב, שהוא זריזות ונקיות (הגהות מיימוני פרק ה' מהלכות דעות.
2:6 It is forbidden to walk with an upright posture (haughtily) and one should not walk four amot [cubits] with an uncovered head (because of respect for the Shechinah) and one should examine one's orifices [to make sure they are clean]. Gloss: One should cover one's whole body, and not go barefoot. And one should accustom oneself to turn aside [to use the bathroom] morning and evening, for this is scrupulous and clean.
Commentary:This halakha comes in the context of rules about a person getting dressed in the morning. In this context, covering one's head right away, before walking any significant distance (4 amot, about a man's height) is both part of getting dressed and is described explicitly as done to give respect to the Shechinah- G-d's presence. Thus, it is a devotional practice, related to our awareness of G-d's presence in the world. However, it is outward, designed to give respect in itself, rather than as a reminder for the person.
It is interesting that head covering is described as religious or devotional in meaning, yet it is set in the context of both modesty and politeness to other people: covering the whole body with clothing, wearing shoes, and keeping one's orifices clean. It suggests to me that the attempt that I, and others, are always making to distinguish between modesty and respect for G-d and polite self-presentation may be not entirely possible. They seem to be quite wrapped up in each other. It's something I'm going to want to think more about.
It is surprising that this is given as straight halakha, while the popular conception of things is that head covering is custom, rather than law. Here, however, it is treated as law, at least in some sense. Oddly, encouraging regular toileting habits is treated in the same area, which is an odd addition- except that the following section of Shulhan Arukh is laws pertaining to using the bathroom, which makes this comment rather a nice literary transition.
Also interesting is the lack of gendering here. My presumption is that this is talking to men, but it never says it explicitly here. I'll have to talk a look at the earlier part of the section to see if there is any clarification, or if it operates on presumption.