tmux-thumbs/tmux-thumbs.sh

39 lines
841 B
Bash
Raw Normal View History

2019-02-04 21:40:45 +00:00
#!/usr/bin/env bash
2020-07-29 18:37:41 +00:00
set -Eeu -o pipefail
2019-02-04 21:40:45 +00:00
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function get-opt-value() {
2020-07-29 18:34:25 +00:00
tmux show -vg "@thumbs-${1}" 2> /dev/null
}
function get-opt-arg() {
local opt type value
opt="${1}"; type="${2}"
value="$(get-opt-value "${opt}")" || true
if [ "${type}" = string ]; then
[ -n "${value}" ] && echo "--${opt}=${value}"
elif [ "${type}" = boolean ]; then
[ "${value}" = 1 ] && echo "--${opt}"
else
return 1
fi
}
PARAMS=(--dir "${CURRENT_DIR}")
function add-param() {
local type opt arg
opt="${1}"; type="${2}"
if arg="$(get-opt-arg "${opt}" "${type}")"; then
PARAMS+=("${arg}")
2019-03-20 23:31:28 +00:00
fi
}
add-param command string
add-param upcase-command string
add-param osc52 boolean
2020-01-20 19:49:38 +00:00
"${CURRENT_DIR}/target/release/tmux-thumbs" "${PARAMS[@]}" || true