-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloating_plugin.tmux
executable file
·65 lines (58 loc) · 2 KB
/
floating_plugin.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
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/helpers.sh"
default_floating_scratch_term="M-i"
default_floating_scratch_to_active_win="M-h"
default_floating_scratch_to_win="M-l"
default_floating_active_pane_to_scratch="M-m"
set_floating_scratch_term_binding() {
local key_bindings="$(get_tmux_option "@floating_scratch_term" "$default_floating_scratch_term")"
local key
for key in $key_bindings; do
tmux bind-key "$key" "if-shell -F '#{==:#{session_name},floating}' {
detach-client
} {
set -gF '@last_session_name' '#S'
popup -d '#{pane_current_path}' -xC -yC -w70% -h70% -E 'tmux new -A -s floating'
}"
done
}
set_floating_scratch_to_win() {
local key_bindings="$(get_tmux_option "@floating_scratch_to_win" "$default_floating_scratch_to_win")"
local key
for key in $key_bindings; do
tmux bind "$key" "if-shell -F '#{!=:#{session_name},floating}' {
break-pane -d
} {
run-shell 'bash -c \"tmux break-pane -s floating -t \"$(tmux show -gvq '@last_session_name'):\"\"'
}"
done
}
set_floating_scratch_to_active_win() {
local key_bindings="$(get_tmux_option "@floating_scratch_to_active_win" "$default_floating_scratch_to_active_win")"
local key
for key in $key_bindings; do
tmux bind "$key" "if-shell -F '#{!=:#{session_name},floating}' {
break-pane
} {
run-shell 'bash -c \"tmux break-pane -d -s floating -t \"$(tmux show -gvq '@last_session_name'):\"\"'
}"
done
}
set_floating_active_pane_to_scratch() {
local key_bindings="$(get_tmux_option "@floating_active_pane_to_scratch" "$default_floating_active_pane_to_scratch")"
local key
for key in $key_bindings; do
tmux bind "$key" "if-shell -F '#{!=:#{session_name},floating}' {
select-pane -m
popup -d '#{pane_current_path}' -xC -yC -w70% -h70% -E 'tmux new -A -s floating tmux join-pane'
}"
done
}
main() {
set_floating_scratch_term_binding
set_floating_scratch_to_active_win
set_floating_scratch_to_win
set_floating_active_pane_to_scratch
}
main