Skip to content

Instantly share code, notes, and snippets.

@mjf
Last active December 24, 2015 15:19
Show Gist options
  • Save mjf/6819431 to your computer and use it in GitHub Desktop.
Save mjf/6819431 to your computer and use it in GitHub Desktop.
GETPOS - Get screen position (column, line)
#! /bin/sh
exec < /dev/tty
ostty=`stty -g`
stty raw -echo min 0
printf -- '\033[6n' > /dev/tty
IFS=\; read -d R -r line col
stty $ostty
printf -- '%d,%d\n' `expr ${col%R} - 1` `expr ${line:2} - 1`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment