From 3aa239dc081e5ab5a0ddcbba8ca9b89ba0815014 Mon Sep 17 00:00:00 2001 From: Duncan Stuart Date: Mon, 4 Mar 2024 09:22:06 +0100 Subject: [PATCH] feat: can restart a pomodoro (#41) --- README.md | 1 + pomodoro.tmux | 7 +++++++ scripts/pomodoro.sh | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e94958..4bfe58d 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ set -g @plugin 'olimorris/tmux-pomodoro-plus' - ` p` to toggle between starting/pausing a Pomodoro/break - ` P` to cancel a Pomodoro/break - ` _` to skip a Pomodoro/break +- ` e` to restart a Pomodoro - ` C-p` to open the Pomodoro timer menu - ` M-p` to set a custom Pomodoro timer diff --git a/pomodoro.tmux b/pomodoro.tmux index 39bd6bb..0413650 100755 --- a/pomodoro.tmux +++ b/pomodoro.tmux @@ -10,6 +10,8 @@ POMODORO_USER_LONG_BREAK_MINS_FILE="$CURRENT_DIR/scripts/user_long_break_mins.tx default_toggle_pomodoro="p" toggle_pomodoro="@pomodoro_toggle" +default_restart_pomodoro="e" +restart_pomodoro="@pomodoro_restart" default_skip_pomodoro="_" skip_pomodoro="@pomodoro_skip" default_cancel_pomodoro="P" @@ -60,6 +62,11 @@ set_keybindings() { tmux bind-key -N "Skip a Pomodoro/break" "$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh skip" done + restart_binding=$(get_tmux_option "$restart_pomodoro" "$default_restart_pomodoro") + for key in $restart_binding; do + tmux bind-key -N "Restart a Pomodoro" "$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh restart" + done + cancel_binding=$(get_tmux_option "$cancel_pomodoro" "$default_cancel_pomodoro") for key in $cancel_binding; do tmux bind-key -N "Cancel a Pomodoro/break" "$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh cancel" diff --git a/scripts/pomodoro.sh b/scripts/pomodoro.sh index d491a01..eaf5ceb 100755 --- a/scripts/pomodoro.sh +++ b/scripts/pomodoro.sh @@ -261,18 +261,27 @@ increment_interval() { } pomodoro_start() { + local verb=${1:-start} + clean_env mkdir -p $POMODORO_DIR write_to_file "$(get_seconds)" "$START_FILE" set_status "in_progress" - increment_interval + + if [ "$verb" = start ]; then + increment_interval + fi refresh_statusline - send_notification "🍅 Pomodoro started!" "Your Pomodoro is underway" + send_notification "🍅 Pomodoro ${verb}ed!" "Your Pomodoro is underway" return 0 } +pomodoro_restart() { + pomodoro_start restart +} + break_start() { write_to_file "$(get_seconds)" "$START_FILE" @@ -491,6 +500,8 @@ main() { pomodoro_toggle elif [ "$cmd" = "start" ]; then pomodoro_start + elif [ "$cmd" = "restart" ]; then + pomodoro_restart elif [ "$cmd" = "skip" ]; then pomodoro_skip elif [ "$cmd" = "cancel" ]; then