I have seen a couple videos of fighter jets and commercial planes with HUD systems and was wondering how do the heads up displays work?
The most common form of head-Up Display (HUD) is simply an out-of-sight display screen reflected in a transparent flat sheet of glass in the viewers line of sight out the cockpit front window.
The glass sheet is called a combiner. It combines the HUD information with the view out of the aircraft.
There are coatings for glass (E.g.) which allow for reflecting a monochromatic image while allowing transmission of other colors.
The display is obviously tailored for that specific use. It must avoid obscuring the view. Therefore it mostly consists of minimal light-colored lines and numerals/letters against a dark background. The dark background allows the pilot to see through the reflection to brighter objects outside - it's a bit like the matt black upper surface typically found on many car dashboards which prevents distracting unwanted images of the top of the dash being reflected into the driver's view out of the windscreen.
Here's an example from Boeing
A HUD display is visible on the left in the pilot's line of sight. Above it, mounted on the ceiling is the projector unit.
The Projector contains optics to make the pilot's view of the display appear to be at infinity (rather than the few feet away it is in reality). This allows the pilot to read the data while their eyes are focused on far-away real-world objects outside the aircraft (runways, weather, other aircraft etc).
Beyond the projection of basic flight instrument data is the use of HUDs for Enhanced Flight Vision Systems (EFVS) which provide a kind of augmented reality display that typically uses external infra-red camera systems to identify landmarks (e.g. runway outlines) that may be obscured to the pilot due to fog etc.