#!/bin/sh
# shellcheck disable=2154

[ -n "$TAOLF" ] && {
    lf -remote "send $id toggle $(printf "'%s'" "$@"); open"
}

term=
[ -n "$SCRATCHPAD" ] && {
    set -- -ft "$@"
    term="$TERMCMD -e"
}

# HACK: workaround for an nvim/taolf bug with opening empty files
[ "$(rifle -c "$XDG_CONFIG_HOME/lf/rifle.conf" | head -1 | cut -d ':' -f 2)" = "editor" ] && $term vim "$@"

set -- -p0 -c "$XDG_CONFIG_HOME/lf/rifle.conf" "$@"
rifle "$@"