tmux-thumbs/tmux-thumbs.sh
Ferran Basora 34d8fa03e9 Adapt old osc52 implementation to swapper and rustbox era
OSC52 support was implemented before two major refactors in tmux-thubs:

- Decouple tmux-thumbs from tmux
- Removal of rustbox with termion

I'm not sure if is the right decision, but I moved the arguments to
swapper land because it looks like more tmux related. If it makes sense
for other terminals to support this we can move it back.

The question we need to answer here if it makes sense for standalone `thumbs`:

```
cat sample/test1 | ./target/release/thumbs --osc52
```
2020-05-30 15:45:37 +00:00

38 lines
790 B
Bash
Executable File

#!/usr/bin/env bash
[ -f ~/.bash_profile ] && source ~/.bash_profile
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