#!/bin/sh -e
#
# ,se - script execute

script="$(command find -L -- "${HOME}/bin" -type f \
  | sed "s|${HOME}/bin/||" | ,picker -p "Run script: ")"

tmpfile="/tmp/$(xxd -l13 -ps /dev/urandom)"
# tmpfile="${TMPDIR:-/tmp}/$(xxd -l13 -ps /dev/urandom)"
zsh -ic "${HOME}/bin/${script}" | tee "${tmpfile}"

# shellcheck disable=SC2312
[ "${GUI_PICKER-}" = 1 ] && notify "[DONE] ${script}" "$(cat "${tmpfile}")"
trap 'command rm -f -- "$tmpfile"' EXIT INT TERM
