-
Notifications
You must be signed in to change notification settings - Fork 6
/
tmux-text-macros.tmux
executable file
·61 lines (59 loc) · 1.96 KB
/
tmux-text-macros.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
#!/usr/bin/env bash
get_tmux_option() {
local option="$1"
local default_value="$2"
local option_value=$(tmux show-option -gqv "$option")
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
}
tmux_macros() {
if [ "$1" = "-r" ];then
set -f
#Macro strings. Everything after the last ":" gets removed and is just there as a search string in fzf
local BASEDIR=$(dirname "$0")
custom=()
if [ -e "$HOME/.tmux/custom-macros" ];then
source "$HOME"/.tmux/custom-macros
fi
alldefaults=()
if [ "$load_defaults" = "on" ];then
source "$BASEDIR"/emojis.sh
source "$BASEDIR"/emojis-narrow.sh
source "$BASEDIR"/emoticons.sh
source "$BASEDIR"/blocks.sh
source "$BASEDIR"/boxdrawing.sh
source "$BASEDIR"/arrows.sh
source "$BASEDIR"/nerd-fonts-icons.sh
alldefaults=(
"${emoticons[@]}"
"${emojis[@]}"
"${emojisnarrow[@]}"
"${blocks[@]}"
"${boxdrawing[@]}"
"${arrows[@]}"
"${nerd_fonts_icons[@]}"
)
fi
all=("${alldefaults[@]}" "${custom[@]}")
tosend="$(for e in "${all[@]}"; do
echo "$e"
done|fzf|sed -e 's/\(.*\):.*/\1/')"
tmux send-keys -t "$PANE" -l "" "$tosend"
else
if [ "$window_mode" = "vertical" ];then
command="tmux split-window -v"
elif [ "$window_mode" = "full" ];then
command="tmux new-window -n Macros"
else
command="tmux split-window -h"
fi
tmux bind "$keybind" run-shell "$command \"PANE='#{pane_id}' $0 -r\""
fi
}
window_mode=$(get_tmux_option "@ttm-window-mode" "horizontal")
load_defaults=$(get_tmux_option "@ttm-load-default-macros" "on")
keybind=$(get_tmux_option "@ttm-keybind" "e")
tmux_macros $@