-
Notifications
You must be signed in to change notification settings - Fork 9
/
tmux-pomodoro.tmux
executable file
·49 lines (43 loc) · 1.19 KB
/
tmux-pomodoro.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
#!/usr/bin/env bash
CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "${CURRENT_DIR}/scripts/helpers.sh"
readonly pomodoro_start_key="$(get_tmux_option "@pomodoro-start-key" "p")"
readonly pomodoro_clear_key="$(get_tmux_option "@pomodoro-clear-key" "P")"
readonly pomodoro_cmd="$(get_pomodoro_cmd)"
append_option() {
local dir=$1
local options=$2
local appendix=$3
if ! echo "$options" | grep -qF "$appendix"; then
case "$dir" in
"left")
options="$appendix $options"
;;
"right")
options="$options $appendix"
;;
esac
fi
echo "$options"
}
update_tmux_option() {
local option=$1
local option_value
option_value=$(get_tmux_option "$option")
local new_option_value
new_option_value=$(append_option left "$option_value" '#('"$pomodoro_cmd"' status)')
tmux set -g "$option" "$new_option_value"
}
main() {
update_tmux_option "status-right"
tmux bind-key "$pomodoro_start_key" run "$pomodoro_cmd start > /dev/null"
tmux bind-key "$pomodoro_clear_key" run "$pomodoro_cmd clear > /dev/null"
}
main
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=sh sw=2 ts=2 et