tmux-thumbs/tmux-thumbs.sh
Javi Merino 19f30d7b22 Fix installation bug in tag 0.7.0
bbf677fda3 ("Improve the matrix of releases") included a fix to cope
with compiled and bundled installations.  However, the check for the
.git/ repository is done from where tmux is launched, not where
tmux-thumbs is installed, so RELEASE_DIR is not properly set always.
This leads to tmux-thumbs always trying to install itself when installed
via tmux-plugin-manager.
2022-02-01 07:56:47 +01:00

54 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeu -o pipefail
# Setup env variables to be compatible with compiled and bundled installations
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -d ${CURRENT_DIR}/.git ]; then
RELEASE_DIR="${CURRENT_DIR}/target/release"
else
RELEASE_DIR=${CURRENT_DIR}
fi
BINARY="${RELEASE_DIR}/thumbs"
if [ ! -f "$BINARY" ]; then
tmux split-window "cd ${CURRENT_DIR} && bash ./tmux-thumbs-install.sh"
exit
fi
function get-opt-value() {
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}")
fi
}
add-param command string
add-param upcase-command string
add-param multi-command string
add-param osc52 boolean
"${RELEASE_DIR}/tmux-thumbs" "${PARAMS[@]}" || true