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
|
#!/usr/bin/env bash
|
||||||
# This is an attempt to replace xdg-open with something sane.
|
# This is an attempt to replace xdg-open with something sane.
|
||||||
|
|
||||||
usage() { printf '%s [-dhv] <uri/file>\n' "${0##*/}"; }
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<- EOF
|
cat <<- EOF
|
||||||
sx-open [-dhv] <uri/file>
|
sx-open [-dhv] <uri/file>
|
||||||
|
@ -62,7 +60,6 @@ handle_file() {
|
||||||
|
|
||||||
set -- "${mime_handlers[@]}"
|
set -- "${mime_handlers[@]}"
|
||||||
|
|
||||||
|
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
cmd=$1; regex=$2
|
cmd=$1; regex=$2
|
||||||
|
|
||||||
|
@ -80,8 +77,21 @@ handle_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# DSL
|
# DSL
|
||||||
uri() { uri_handlers+=( "$1" "$2" ); }
|
uri() {
|
||||||
mime() { mime_handlers+=( "$1" "$2" ); }
|
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\+\.\-]+:.+ ]]
|
is_uri() [[ $1 =~ ^[a-zA-Z][a-zA-Z0-9\+\.\-]+:.+ ]]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user