tmux-thumbs/tmux-thumbs.sh

54 lines
1.3 KiB
Bash
Raw Normal View History

2019-02-04 21:40:45 +00:00
#!/usr/bin/env bash
2019-12-11 10:10:52 +00:00
[ -f ~/.bash_profile ] && source ~/.bash_profile
2019-03-06 17:04:05 +00:00
PARAMS=()
function add-boolean-param {
2019-03-28 13:02:15 +00:00
VALUE=$(tmux show -vg @thumbs-$1 2> /dev/null)
2019-03-20 23:31:28 +00:00
if [[ "${VALUE}" == "1" ]]; then
PARAMS+=("--$1")
2019-03-20 23:31:28 +00:00
fi
}
function add-option-param {
2019-03-28 13:02:15 +00:00
VALUE=$(tmux show -vg @thumbs-$1 2> /dev/null)
2019-03-20 23:31:28 +00:00
if [[ ${VALUE} ]]; then
PARAMS+=("--$1=${VALUE}")
2019-03-20 23:31:28 +00:00
fi
}
function add-multi-param {
2019-03-28 13:02:15 +00:00
while read -r ITEM_KEY; do
VALUE=$(tmux show -vg $ITEM_KEY 2> /dev/null)
PARAMS+=("--$1=${VALUE}")
2019-03-28 13:02:15 +00:00
done < <(tmux show -g 2> /dev/null | grep thumbs-$1- | cut -d' ' -f1)
2019-03-20 23:31:28 +00:00
}
add-boolean-param "reverse"
add-boolean-param "unique"
add-option-param "alphabet"
add-option-param "position"
add-option-param "fg-color"
add-option-param "bg-color"
add-option-param "hint-bg-color"
add-option-param "hint-fg-color"
add-option-param "select-fg-color"
2019-12-11 10:10:52 +00:00
add-option-param "select-bg-color"
add-option-param "command"
add-option-param "upcase-command"
add-multi-param "regexp"
add-boolean-param "contrast"
# 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
2019-03-09 22:39:16 +00:00
2019-03-10 09:45:22 +00:00
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2019-03-05 08:10:41 +00:00
2019-12-08 23:21:25 +00:00
${CURRENT_DIR}/target/release/tmux-thumbs