Re:macOS command-line tools you might not know about
by svieira on Tuesday June 27, 2023 @10:35AM
(#36493443)
And I have one that unifies _both_ to `clip` so you can put the same command in both sides of the pipe, e. g. to turn a line-delimited blob on your clipboard to a space-separated one:
https://github.com/svieira/dotfiles/blob/a3654d6a194e3689978...
[ Parent
| on HN ]
Re:macOS command-line tools you might not know about
by pmarreck on Wednesday June 28, 2023 @07:30AM
(#36504955)
Holy crap. Of course! You win! Amazing!
Simple is genius
Re:macOS command-line tools you might not know about
by pmarreck on Wednesday June 28, 2023 @09:27AM
(#36506140)
So to check if there's anything sitting on stdin without reading it I've been using
`if read -r -t0; then` # returns true if there is data but times out instantly so it doesn't consume any
Is `[ -t 0 ]` more idiomatic? Apparently it fails on this case: function < file
`read -r -t0` is Bash-only though and not POSIX, but it will work regardless of what type of data is on stdin
Re:macOS command-line tools you might not know about
by naniwaduni on Thursday June 29, 2023 @01:41PM
(#36523875)
[ -t 0 ] instead checks whether stdin (fd 0) is a tty.