Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action: restart a pomodoro #41

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ set -g @plugin 'olimorris/tmux-pomodoro-plus'
- `<tmux-prefix> p` to toggle between starting/pausing a Pomodoro/break
- `<tmux-prefix> P` to cancel a Pomodoro/break
- `<tmux-prefix> _` to skip a Pomodoro/break
- `<tmux-prefix> e` to restart a Pomodoro
- `<tmux-prefix> C-p` to open the Pomodoro timer menu
- `<tmux-prefix> M-p` to set a custom Pomodoro timer

Expand Down
7 changes: 7 additions & 0 deletions pomodoro.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
15 changes: 13 additions & 2 deletions scripts/pomodoro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -490,6 +499,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
Expand Down