macro support
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
a77e18d908
commit
0b3468ed49
13
sx-open
13
sx-open
|
@ -23,7 +23,7 @@ act() {
|
|||
# 3: no handler
|
||||
handle_target() {
|
||||
declare -n result=$1
|
||||
declare h cmd regex target_is_file target target_left
|
||||
declare h cmd regex target_is_file target target_left cmd_is_template
|
||||
target_is_file=0
|
||||
target=$2
|
||||
target_left=$target
|
||||
|
@ -46,8 +46,17 @@ handle_target() {
|
|||
while (( $# )); do
|
||||
cmd=( $1 ); regex=$2
|
||||
|
||||
for c in "${!cmd[@]}"; do
|
||||
if [[ "${cmd[c]}" == '%target%' ]]; then
|
||||
cmd_is_template=1
|
||||
cmd[c]="$target"
|
||||
fi
|
||||
done
|
||||
|
||||
(( cmd_is_template )) || cmd+=( "$target" )
|
||||
|
||||
if [[ "$target_left" =~ $regex ]]; then
|
||||
act "${cmd[@]}" "$target"; result=$?
|
||||
act "${cmd[@]}"; result=$?
|
||||
(( result )) && return 1
|
||||
|
||||
return 0
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
# 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.
|
||||
|
||||
# <cmd> macros:
|
||||
# %target% — The first argument to this script.
|
||||
# If not found, target is appended to the end of <cmd>
|
||||
# example:
|
||||
#uri 'browser %target% --profile=work' '^https://.+\.?workdomain.tld.*'
|
||||
|
||||
# scheme <cmd> <scheme>[ <scheme> ...]
|
||||
#scheme browser http https
|
||||
#scheme steam steam
|
||||
|
|
Loading…
Reference in New Issue
Block a user