mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
24 lines
692 B
Bash
24 lines
692 B
Bash
#!/bin/sh
|
|||
|
|
# brave-new-tab URL
|
||
|
|
# Open URL in a new tab of the running Brave Origin (its last active window),
|
||
|
|
# or start Brave Origin with it. Detached, so the caller never blocks.
|
||
|
|
# Without a scheme, localhost, *.localhost, *.local, and 127.x get http://;
|
||
|
|
# anything else gets https://.
|
||
|
|
set -eu
|
||
|
|
|
||
|
|
[ $# -eq 1 ] || { echo "usage: brave-new-tab URL" >&2; exit 2; }
|
||
|
|
|
||
|
|
url=$1
|
||
|
|
case $url in
|
||
|
|
*://* | about:*) ;;
|
||
|
|
*)
|
||
|
|
host=${url%%[/?#]*}
|
||
|
|
host=$(printf '%s' "${host%:*}" | tr '[:upper:]' '[:lower:]')
|
||
|
|
case $host in
|
||
|
|
localhost | *.localhost | *.local | 127.*) url="http://$url" ;;
|
||
|
|
*) url="https://$url" ;;
|
||
|
|
esac
|
||
|
|
;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
exec setsid -f brave-origin --new-tab "$url" >/dev/null 2>&1
|