Search code examples
linuxbashfish

How can I simulate user input in fish


So I want to have a function that displays rsclock, then quits. To exit rsclock, user presses 'Q'. So I want to simulate this input in fish. How can I?


Solution

  • Ordinarily you could do this with a pipe, but rsClock explicitly opens /dev/tty instead of just reading from stdin, so it would be non-trivial with any shell.

    One approach would be to send SIGINT after a delay:

    #!/bin/sh
    
    (sleep 1; killall -INT rsclock) &
    rsclock
    tput cnorm
    

    but the path of least resistance is probably to just modify rsclock directly to support a timeout.