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
|
|
|
|
2022-01-30 21:28:44 +00:00
|
|
|
# Setup env variables to be compatible with compiled and bundled installations
|
2020-07-29 18:35:42 +00:00
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2022-01-31 21:33:34 +00:00
|
|
|
RELEASE_DIR="${CURRENT_DIR}/target/release"
|
2020-07-29 18:35:42 +00:00
|
|
|
|
2022-01-31 21:33:34 +00:00
|
|
|
THUMBS_BINARY="${RELEASE_DIR}/thumbs"
|
|
|
|
TMUX_THUMBS_BINARY="${RELEASE_DIR}/tmux-thumbs"
|
2022-02-02 22:09:02 +00:00
|
|
|
VERSION=$(grep 'version =' "${CURRENT_DIR}/Cargo.toml" | grep -oe "[0-9]\+.[0-9]\+.[0-9]\+")
|
2021-12-26 19:15:07 +00:00
|
|
|
|
2022-01-31 21:33:34 +00:00
|
|
|
if [ ! -f "$THUMBS_BINARY" ]; then
|
2021-12-26 19:15:07 +00:00
|
|
|
tmux split-window "cd ${CURRENT_DIR} && bash ./tmux-thumbs-install.sh"
|
|
|
|
exit
|
2022-02-01 21:50:31 +00:00
|
|
|
elif [[ $(${THUMBS_BINARY} --version) != "thumbs ${VERSION}" ]]; then
|
|
|
|
tmux split-window "cd ${CURRENT_DIR} && bash ./tmux-thumbs-install.sh update"
|
|
|
|
exit
|
2021-12-26 19:15:07 +00:00
|
|
|
fi
|
|
|
|
|
2020-07-29 19:10:09 +00:00
|
|
|
function get-opt-value() {
|
2020-07-29 18:34:25 +00:00
|
|
|
tmux show -vg "@thumbs-${1}" 2> /dev/null
|
|
|
|
}
|
|
|
|
|
2020-07-29 19:10:09 +00:00
|
|
|
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
|
2020-05-30 15:45:37 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-07-29 19:10:09 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-07-29 19:10:09 +00:00
|
|
|
add-param command string
|
|
|
|
add-param upcase-command string
|
2021-07-10 15:07:17 +00:00
|
|
|
add-param multi-command string
|
2020-07-29 19:10:09 +00:00
|
|
|
add-param osc52 boolean
|
2020-01-20 19:49:38 +00:00
|
|
|
|
2022-01-31 21:33:34 +00:00
|
|
|
"${TMUX_THUMBS_BINARY}" "${PARAMS[@]}" || true
|