When inside a Terminal, hold down Ctrl and press R. This action invokes reverse-i-search. Now, enter a letter - like W to find a match for the most recent command in your history that starts with the same alphabet. Keep typing to narrow down your match. When found, press Enter.