-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpower-zoom.tmux
executable file
·72 lines (58 loc) · 2.15 KB
/
power-zoom.tmux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
#
# Copyright (c) 2022: [email protected]
# License: MIT
#
# Part of https://github.com/jaclu/tmux-power-zoom
#
# Dependency: 2.6 - select-pane -T introduced with this version
#
# shellcheck disable=SC2154
# shellcheck disable=SC1007
CURRENT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
SCRIPTS_DIR="$CURRENT_DIR/scripts"
# shellcheck source=/dev/null
. "$SCRIPTS_DIR/utils.sh"
#
# By printing a NL and date, its easier to keep separate runs apart
#
log_it ""
log_it "$(date)"
set --
#
# Generic plugin setting I use to add Notes to plugin keys that are bound
# This makes this key binding show up when doing <prefix> ?
# If not set to "Yes", no attempt at adding notes will happen.
# bind-key Notes were added in tmux 3.1, so should not be used on older versions!
#
if bool_param "$(get_tmux_option "@use_bind_key_notes_in_plugins" "No")"; then
set -- "$@" -N "plugin: $plugin_name"
fi
mouse_action="$(get_tmux_option "@power_zoom_mouse_action")"
if [[ -n "$mouse_action" ]]; then
#
# First select the mouse-over pane, then trigger zoom, otherwise the
# focused pane would get zoomed, and not the clicked one.
#
# shellcheck disable=SC2089
mouse_cmd="select-pane -t= \; run-shell -t= \"$SCRIPTS_DIR/power_zoom.sh\""
# shellcheck disable=SC2086,2090 #options & mouse_cmd can't be quoted
$TMUX_BIN bind $options -n "$mouse_action" $mouse_cmd
log_it "Mouse action: $mouse_action"
fi
trigger_key=$(get_tmux_option "@power_zoom_trigger" "$default_key")
log_it "trigger_key=[$trigger_key]"
if bool_param "$(get_tmux_option "@power_zoom_without_prefix" "No")"; then
set -- "$@" -n
log_it "Not using prefix"
fi
#
# clear list of zoomed panes, should make it smarter so it leaves currently
# present items, this will leave them hanging on a conf source, but that
# is minor compared to the risk of having crash left-overs causing future
# havoc, the zoomed pane is left intact and dead placeholders can easily be
# killed.
#
$TMUX_BIN set-option @power_zoom_state ""
# shellcheck disable=SC2086 #options can't be quoted
$TMUX_BIN bind-key "$@" "$trigger_key" run-shell "$SCRIPTS_DIR"/power_zoom.sh