Skip to content

Instantly share code, notes, and snippets.

@bashbunni
Created October 27, 2022 21:41
Show Gist options
  • Save bashbunni/f6b04fc4703903a71ce9f70c58345106 to your computer and use it in GitHub Desktop.
Save bashbunni/f6b04fc4703903a71ce9f70c58345106 to your computer and use it in GitHub Desktop.
CLI Pomodoro for Mac
# I'll be doing another one for Linux, but this one will give you
# a pop up notification and sound alert (using the built-in sounds for macOS)
# Requires https://github.com/caarlos0/timer to be installed
# Mac setup for pomo
alias work="timer 60m && terminal-notifier -message 'Pomodoro'\
-title 'Work Timer is up! Take a Break 😊'\
-appIcon '~/Pictures/pumpkin.png'\
-sound Crystal"
alias rest="timer 10m && terminal-notifier -message 'Pomodoro'\
-title 'Break is over! Get back to work 😬'\
-appIcon '~/Pictures/pumpkin.png'\
-sound Crystal"
@SmithWebDev
Copy link

i've been playing around and attempting to add a time input, but it doesnt recognize an argument. I've looked over my other alias and have no issues with adding an argument.

alias work="timer $1 && osascript -e 'display notification \"☕\" with title \"Work Timer is up!\" subtitle \"Take a Break 😊\" sound name \"Crystal\"' && say \"Phase complete\""

@umkl
Copy link

umkl commented Apr 9, 2024

i've been playing around and attempting to add a time input, but it doesnt recognize an argument. I've looked over my other alias and have no issues with adding an argument.

alias work="timer $1 && osascript -e 'display notification \"☕\" with title \"Work Timer is up!\" subtitle \"Take a Break 😊\" sound name \"Crystal\"' && say \"Phase complete\""

alias work='work_alias(){ timer "$1" && osascript -e "display notification \"☕\" with title \"Work Timer is up!\" subtitle \"Take a Break 😊\" sound name \"Crystal\"" && say "Phase complete"; unset -f work_alias; }; work_alias'

this works for me

@realFranco
Copy link

open source! 💕

@begs
Copy link

begs commented Aug 20, 2024

For anyone who wants the notification sound to play during "Do not disturb", try using afplay as the -ignoreDnD flag on terminal-notifier is broken.
For example:

alias work="timer 30m -n work! --format 24h && terminal-notifier -message 'Pomodoro'\
	-title 'break!'\
	&& afplay /System/Library/Sounds/Glass.aiff"

@rafaeltenoriogama
Copy link

Okay, I have a plenty time to figure out how works in fish shell with kitty terminal. But in anyone want this, just copy and paste:

if status is-interactive
    alias job="pomodoro work"
    alias pause="pomodoro break"

    function pomodoro
        set -l session_type $argv[1]
        set -l work_icon ~/Imagens/niqaba.png # Altere para o caminho do ícone desejado

        # Se for uma sessão de trabalho, definir para 1 hora (3600 segundos)
        if test "$session_type" = work
            # 60 minutes duration_seconds is 3600
            notify-send -i $work_icon Pomodoro "🟢 Work session started! You have 60 minutes."
            timer 36
            # Se for uma pausa, definir para 15 minutos (900 segundos)
        else if test "$session_type" = break
            # 10 minutes duration_seconds is 900
            notify-send -i $work_icon Pomodoro "🟢 Break session started! You have 15 minutes."
            timer 9
        else
            echo "Invalid session type" >&2
            return 1
        end

        # Notificação de fim de sessão
        if test "$session_type" = work
            notify-send -i $work_icon Pomodoro "Work Timer is up! Take a Break 😊"
        else if test "$session_type" = break
            notify-send -i $work_icon Pomodoro "Break is over! Get back to work 😬"
        end
    end
end

@emmak3l
Copy link

emmak3l commented Sep 17, 2024

For anyone who wants the notification sound to play during "Do not disturb", try using afplay as the -ignoreDnD flag on terminal-notifier is broken. For example:

alias work="timer 30m -n work! --format 24h && terminal-notifier -message 'Pomodoro'\
	-title 'break!'\
	&& afplay /System/Library/Sounds/Glass.aiff"

I work in DnD mode too so I was running into the same issue! The way I fixed it so that it would both show the notification and play the sound is by going to System Preferences > Focus > Do Not Disturb > and then adding terminal-notifier to Allowed Apps. Now it works like a charm :)

@botscholar-scott
Copy link

Sorry I'm late to the game here. So do you just sacrifice a terminal when you run this? Or you ctrl-z + bg your work alias so you can still use the terminal? When I saw the youtube I was imagining it would adjust the prompt or something.

@rafaeltenoriogama
Copy link

Sorry I'm late to the game here. So do you just sacrifice a terminal when you run this? Or you ctrl-z + bg your work alias so you can still use the terminal? When I saw the youtube I was imagining it would adjust the prompt or something.

Brother you need to use Tmux or smth like that to split the terminal and work on the same window. Otherwise, yes, you will sacrifice one terminal window just for this.

Example of how Tmux works:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment