package main
import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"os/exec"
	"regexp"
	"strings"
)
func main() {
	// $ echo -e "\033[6n" | read -dR
	cmd := exec.Command("echo", "-e", fmt.Sprintf("%c[6n", 27))
	randomBytes := &bytes.Buffer{}
	cmd.Stdout = randomBytes
	// Start command asynchronously
	_ = cmd.Start()
	// capture keyboard output from echo command
	reader := bufio.NewReader(os.Stdin)
	cmd.Wait()
	// by printing the command output, we are triggering input
	fmt.Print(randomBytes)
	text, _ := reader.ReadSlice('R') // how to get this to not require manual newline?
	// check for the desired output
	if strings.Contains(string(text), ";") {
		re := regexp.MustCompile(`\d+;\d+`)
		line := re.FindString(string(text))
		fmt.Printf("works! line,Col: %s\n", line)
	} else {
		fmt.Println("it does not work. womp womp.")
	}
}