diff --git a/spells/cantrips/fathom-cursor b/spells/cantrips/fathom-cursor index b83048f..42ad24b 100755 --- a/spells/cantrips/fathom-cursor +++ b/spells/cantrips/fathom-cursor @@ -17,7 +17,21 @@ fathom_cursor() { done # Get the position of the cursor - position=$(stty -echo; printf "\033[6n"; (trap 'exit 142' ALRM; sh -c 'sleep 0.1; kill -ALRM $$' &) IFS=';' read -r ROW COL; stty echo; printf "%s;%s" "${ROW#*[}" "${COL}") + + # Save the current terminal state + old_state=$(stty -g) + + # Disable terminal echo and canonical mode + stty -echo -icanon + + # Request the cursor position + printf "\033[6n" + IFS='[;' read -r _ ROW COL + + # Restore the terminal state + stty "$old_state" + + position="$COL;$ROW" if [ $x = true ] && [ $y = true ]; then if [ $verbose = true ]; then