4 ms·
xdg-open is so frustrating. Its defaults are wrong and its a pain to reconfigure. I replaced xdg-open with this shell script that simply copies the url and post
by psanford 6y ago
xdg-open is so frustrating. Its defaults are wrong and its a pain to reconfigure. I replaced xdg-open with this shell script that simply copies the url and posts a desktop notification saying it did so (I got the idea from a post on twitter). I'm much happier to make the decision on my own what to do with external file handlers.
#!/bin/sh
echo -n "$1" | xclip -selection primary; notify-send "URL Copied" "$1"
- Blikkentrekker 6y agoIt should be noted that the behavior of `echo` in this case is notable not standardized with regards to what should happen if `$1` starts with a dash, and whether it should interpret several special control sequences or not. It is for this reason that `echo` is generally frowned upon for programmatic input, and `printf %s "$1"` is recommended; as this is guaranteed to not interpret, and copy dash-leading strings to the output verbātim.
- geofft 6y agoPretty sure the behavior of echo is standardized on all machines that have notify-send installed.
- yjftsjthsd-h 6y agonotify-send works on Arch Linux, FreeBSD, and Alpine Linux, each of which uses a different echo(1).
- Blikkentrekker 6y agoYou would be wrong as pointed out below. Modern shells also typically have `echo` as a builtin and can have quite different behavior. https://stackoverflow.com/questions/33784892/bash-vs-dash-behavior-with-the-command-echo-ne-hello-n https://stackoverflow.com/questions/33784892/bash-vs-dash-be...