tmux-thumbs/tmux-thumbs.sh
Robert Estelle 85d151df03 sh: Do not source ~/.bash_profile
This isn't an interactive script. Any relevant environment should
already be inherited from tmux, and sourcing ~/.bash_profile may cause
~/.bashrc to be sourced with unexpected effects.
2020-08-04 18:58:50 +02:00

36 lines
740 B
Bash
Executable File

#!/usr/bin/env bash
PARAMS=()
function add-boolean-param {
VALUE=$(tmux show -vg @thumbs-$1 2> /dev/null)
if [[ "${VALUE}" == "1" ]]; then
PARAMS+=("--$1")
fi
}
function add-option-param {
VALUE=$(tmux show -vg @thumbs-$1 2> /dev/null)
if [[ ${VALUE} ]]; then
PARAMS+=("--$1=${VALUE}")
fi
}
add-option-param "command"
add-option-param "upcase-command"
add-boolean-param "osc52"
# Remove empty arguments from PARAMS.
# Otherwise, they would choke up tmux-thumbs when passed to it.
for i in "${!PARAMS[@]}"; do
[ -n "${PARAMS[$i]}" ] || unset "PARAMS[$i]"
done
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
${CURRENT_DIR}/target/release/tmux-thumbs --dir "${CURRENT_DIR}" "${PARAMS[@]}"
true