Last active
January 22, 2025 15:12
-
-
Save sverweij/406b7b5e7b164bc06d0861cb8833a518 to your computer and use it in GitHub Desktop.
Scrappy script to open stdin into whichever is associated with .html extensions (MacOS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
RANDOMNAME=$(mktemp).html || exit 1 | |
cat /dev/stdin > $RANDOMNAME | |
open $RANDOMNAME | |
# to open with an other browser (or program) replace the above line with | |
# something like ... | |
# open -a safari $RANDOMNAME | |
# open -a firefox $RANDOMNAME | |
# inelegant and not foolproof (i.e. if the browser takes longer than the | |
# sleep time to open the file, it'll be _gone_) | |
trap "sleep 2.4s && rm $RANDOMNAME &" EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment