Home > Mobile >  How can I simulate user input in fish
How can I simulate user input in fish

Time:01-24

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?

CodePudding user response:

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.

  •  Tags:  
  • Related