diff --git a/sx-open b/sx-open index a9e0cf8..59b41cc 100755 --- a/sx-open +++ b/sx-open @@ -1,8 +1,6 @@ #!/usr/bin/env bash # This is an attempt to replace xdg-open with something sane. -usage() { printf '%s [-dhv] \n' "${0##*/}"; } - usage() { cat <<- EOF sx-open [-dhv] @@ -62,7 +60,6 @@ handle_file() { set -- "${mime_handlers[@]}" - while (( $# )); do cmd=$1; regex=$2 @@ -80,8 +77,21 @@ handle_file() { } # DSL -uri() { uri_handlers+=( "$1" "$2" ); } -mime() { mime_handlers+=( "$1" "$2" ); } +uri() { + declare r handler=$1; shift + + for r in "$@"; do + uri_handlers+=( "$handler" "$r" ) + done +} + +mime() { + declare r handler=$1; shift + + for r in "$@"; do + uri_handlers+=( "$1" "$r" ) + done +} is_uri() [[ $1 =~ ^[a-zA-Z][a-zA-Z0-9\+\.\-]+:.+ ]]