Allow multiple regexes to be specified
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
8493a07fdc
commit
c054744d48
20
sx-open
20
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] <uri/file>\n' "${0##*/}"; }
|
||||
|
||||
usage() {
|
||||
cat <<- EOF
|
||||
sx-open [-dhv] <uri/file>
|
||||
|
@ -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\+\.\-]+:.+ ]]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user