diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-23 18:32:47 -0800 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-26 20:21:16 -0800 |
| commit | 78c397c3f7a9eea0f764c66270f47613f8e015d3 (patch) | |
| tree | ebaa4d1bcf595719c55167deadd7847452ebedfe /tests/tmux.sh | |
| parent | Fix format of installation config in readme file (diff) | |
| download | tmux-toggle-term-78c397c3f7a9eea0f764c66270f47613f8e015d3.zip | |
Refactor bats tests
Diffstat (limited to 'tests/tmux.sh')
| -rw-r--r-- | tests/tmux.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/tmux.sh b/tests/tmux.sh new file mode 100644 index 0000000..23c2700 --- /dev/null +++ b/tests/tmux.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bats + +tmux_new_session() { + tmux_cmd new-session -d -s "$1" +} + +tmux_kill_server() { + tmux_cmd kill-server || true +} + +tmux_pane_count() { + num_panes=$(tmux_cmd list-panes | wc -l | sed 's/^[[:space:]]*//g') + echo "$num_panes" +} + +tmux_active_panes() { + active_panes=$(tmux_cmd list-panes -F '#{pane_active}' | tr '\n' '-' | sed 's/-$//g') + echo "$active_panes" +} + +tmux_is_zoomed() { + is_zoomed=$(tmux_cmd list-panes -F '#{window_zoomed_flag}') + if echo "$is_zoomed" | grep -q 1; then + echo 'true' + else + echo 'false' + fi +} + +tmux_set_option() { + option="$1" + value="$2" + tmux_cmd set-option -g "$option" "$value" +} + +tmux_get_key_bindings() { + tmux_cmd list-keys 2>/dev/null | grep "toggle-term" || echo "" +} + +tmux_cmd() { + tmux -f "$TMUX_CONFIG_PATH" -L "$TMUX_SOCKET" "$@" +} + +tmux_has_prefix_binding() { + key="$1" + mode="$2" + tmux_get_key_bindings | grep -q "bind-key.*-T prefix.*${key}.*toggle-term.sh $mode" +} + +tmux_has_root_binding() { + key="$1" + mode="$2" + tmux_get_key_bindings | grep -q "bind-key.*-T root.*\"*${key}\"*.*toggle-term.sh $mode" +} |