From 739c430e42afb447c87697d50e87c2d1d0d1149b Mon Sep 17 00:00:00 2001 From: fbt Date: Fri, 27 Jul 2018 16:49:08 +0300 Subject: [PATCH] even smarter DSL Signed-off-by: fbt --- sx-open | 8 ++++++++ sx-open.cfg | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sx-open b/sx-open index 59b41cc..75704db 100755 --- a/sx-open +++ b/sx-open @@ -93,6 +93,14 @@ mime() { done } +scheme() { + declare r handler=$1; shift + + for s in "$@"; do + uri_handlers+=( "$handler" "^$s:" ) + done +} + is_uri() [[ $1 =~ ^[a-zA-Z][a-zA-Z0-9\+\.\-]+:.+ ]] main() { diff --git a/sx-open.cfg b/sx-open.cfg index 4d27fe0..e8cafb4 100644 --- a/sx-open.cfg +++ b/sx-open.cfg @@ -1,12 +1,17 @@ #!syntax bash # Configuration file for sx-open # Note that as sx-open checks the regexes in order, they should be placed in order from specific to less so. -# Format: type cmd regex -# Examples: +# scheme [ ...] +#scheme browser http https +#scheme steam steam -#uri browser '^https?:' +# Or you can specify a regex for the entire uri: +# uri [ ...] #uri steam '^steam:' +#uri browser '^(https?|ftp):' +# Mime types for filesystem targets: +# mime [ ...] #mime sxiv '^image/' #mime libreoffice '^application/msword$'