You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
529 B
18 lines
529 B
2 years ago
|
#!/usr/bin/env sh
|
||
|
|
||
|
# This spell reveals the x and y coordinates of the cursor in the terminal window.
|
||
|
|
||
|
# Define the function to calculate the position of the cursor
|
||
|
fathom_cursor() {
|
||
|
# Get the position of the cursor
|
||
|
position=$(IFS=';' read -sdR -p $'\E[6n' ROW COL; printf "%s;%s" "${ROW#*[}" "$COL")
|
||
|
|
||
|
# Output the position of the cursor
|
||
|
echo "Cursor position: $position"
|
||
|
}
|
||
|
|
||
|
# Check if the script is being called from another script
|
||
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
||
|
# If not, call the function
|
||
|
fathom_cursor
|
||
|
fi
|