Bash · 915 bytes Raw Blame History
1 #!/bin/bash
2 # Test what escape sequences WezTerm actually sends for F-keys
3 # Press F8, F12, Shift-F12, etc. and see what comes through
4
5 echo "=== Raw Key Sequence Tester ==="
6 echo "Press F8, F12, or Shift-F12, then Ctrl+C to exit"
7 echo "This will show the EXACT escape sequences received"
8 echo ""
9
10 # Use od to show the raw bytes of each key press
11 while true; do
12 echo -n "Press a key: "
13 # Read one key sequence with timeout
14 IFS= read -rsn1 char
15
16 # If it's ESC, read the rest of the sequence
17 if [ "$char" = $'\x1b' ]; then
18 # Read the next character(s) quickly
19 rest=""
20 while IFS= read -rsn1 -t 0.01 c; do
21 rest="$rest$c"
22 done
23 full="$char$rest"
24
25 # Show as hex and as escaped string
26 echo -n "$full" | od -An -tx1 | tr -d ' \n'
27 echo -n " = ESC"
28 echo "$rest" | sed 's/./[&]/g'
29 else
30 echo "$char"
31 fi
32 done