Al-Adab Al-Mufrad, Book 43, Hadith 20 (In-Book)

Sahl ibn Sa'd told him that a man looked from a room through the door of the Prophet, may Allah bless him and grant him peace, while the Prophet, may Allah bless him and grant him peace, had a comb with which he was scratching his hair. When the Prophet, may Allah bless him and grant him peace, saw him, he said, "If I had known that you were looking at me, I would have stabbed you in the eye with this!"

حَدَّثَنَا عَبْدُ اللهِ بْنُ صَالِحٍ، قَالَ‏:‏ حَدَّثَنَا اللَّيْثُ قَالَ‏:‏ حَدَّثَنِي ابْنُ شِهَابٍ، أَنَّ سَهْلَ بْنَ سَعْدٍ أَخْبَرَهُ، أَنَّ رَجُلاً اطَّلَعَ مِنْ جُحْرٍ فِي بَابِ النَّبِيِّ صلى الله عليه وسلم، وَمَعَ النَّبِيِّ صلى الله عليه وسلم مِدْرًى يَحُكُّ بِهِ رَأْسَهُ، فَلَمَّا رَآهُ النَّبِيُّ صلى الله عليه وسلم قَالَ‏:‏ لَوْ أَعْلَمُ أَنَّكَ تَنْتَظِرُنِي لَطَعَنْتُ بِهِ فِي عَيْنِكَ‏.‏

sunnah.com