-
-
Save bashbunni/f6b04fc4703903a71ce9f70c58345106 to your computer and use it in GitHub Desktop.
# 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" |
I'm getting an error
zsh: command not found: timer
(( I'm thinking that some package is missing but couldn't find one
she mentioned that you need to install https://github.com/caarlos0/timer
. if you have brew you can via brew install caarlos0/tap/timer
π₯«
Hey where can i save this code, so that i dont have to paste it in the terminal when im closing it, or do you just execute the file?
You put it in your $HOME/.zshrc
https://github.com/caarlos0/timer#install
brew install caarlos0/tap/timer
if you have brew you can via
brew install caarlos0/tap/timer
@AD0791 through taps in brew like above. If you wanna read more before installing it, it's on GitHub.
osascript -e 'display notification "β" with title "Work Timer is up!" subtitle "Take a Break π" sound name "Crystal"'
ππ»
hey my app icon is always not correct. i put an png in my Picture dictonery and named it 'pumpkin.png'. Has anyone a fix?
Nice
Can someone please explain how exactly to run it. I couldn't figure it out :/
Can someone please explain how exactly to run it. I couldn't figure it out :/
Hey.
Lets say u didnt install homebrew.
So just google homebrew mac. After installing it then just run the following commands
brew install caarlos0/tap/timer
brew install terminal-notifier
I installed oh-my-zsh. You cann install it too per:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
so after this open a terminal and type in "pwd"
you should be in '/Users/{YourPcName}
next command is 'ls -a' (you dont have to do that but you can see als hiden files)
now you can check if a '.zshrc' file exits.
now you can use an Editor to open this file, chose nano if your beginner or install vscode and use it:
-
nano .zshrc
copy the code above from bashbunni and STRG-V it at the end of the file.
edit as needed (custom times for work and break)
use the commands to save and exit -
vi .zshrc
move to the end of the file.
now press a to get in 'append-mode' then press enter to make space.
STRG-V the code in π
edit as needed (custom times for work and break)
press ESC to go back in 'Normal mode"
if you panic ':q' for abort mission in vim
then press SHIFT-Z-Z (Shift and to times Z) -> to safe and Exit the File -
code .zshrc (i dont know, but i think this is if you have installed vscode)
scroll down, paste the code in, edit as needed (custom times for work and break), press safe
now you should use work and break, and it should be working.. π
also you can close the terminal open a new one and it also should work again.
if you want to change the times for work and break or the alis just open terminal ->
check with 'pwd' where you are and start edit the .zshrc file with nano, vi(m) or (vs)code π
go to your settings at your mac and set notifications on for the terminal-notifier!
Hope i could help!
oh and bashbunni set the alias to work and break. if you just installed the timer you can set a timer by
'timer {number}[s or m} -n {title}'
for example 'timer 45min -n math study'
if you just type work it will run with the time and name in the config.
so default would be if you copy the code: 60min
so jo dont need to write every time: timer 60m -n work
Feel free to create your own alias π
This is great! How can I make this auto start work and auto start rest?
I test using this code.
When I run work
command, the terminal auto execute rest
command. But after the rest timer is up, the work
command isn't execute. Vice versa when I run rest
command first.
alias work="timer 5s && terminal-notifier -message 'Timer is up! Take a
Break' && rest
-title 'Work Timer is up! Take a Break π'
-appIcon '~/Pictures/tomato.png'
-sound Crystal"
alias rest="timer 10s && terminal-notifier -message 'Break is over! Get
back to work' && work
-title 'Break is over! Get back to work π¬'
-appIcon '~/Pictures/tomato.png'
-sound Crystal"
Using that, if you use rest, it does that, then work, then dies out with the same error. I'm guessing something's preventing it from infinite looping (but couldn't tell you what)
This is great! How can I make this auto start work and auto start rest?
I test using this code. When I run
work
command, the terminal auto executerest
command. But after the rest timer is up, thework
command isn't execute. Vice versa when I runrest
command first.alias work="timer 5s && terminal-notifier -message 'Timer is up! Take a Break' && rest -title 'Work Timer is up! Take a Break π' -appIcon '~/Pictures/tomato.png' -sound Crystal"
alias rest="timer 10s && terminal-notifier -message 'Break is over! Get back to work' && work -title 'Break is over! Get back to work π¬' -appIcon '~/Pictures/tomato.png' -sound Crystal"
Hey i just made a function:
pomo(){
echo "How many rounds you want to do?"
read count;
for i in {1..$count};
do
work;
sleep 1;
rest;
done
}
hope it solves your problem. just type the function name in the terminal: here -> pomo
Oh, and put the code under the two alias!
*Thanks at @nayakayp for finding the lost bracket π
This is great! How can I make this auto start work and auto start rest?
I test using this code. When I runwork
command, the terminal auto executerest
command. But after the rest timer is up, thework
command isn't execute. Vice versa when I runrest
command first.
alias work="timer 5s && terminal-notifier -message 'Timer is up! Take a Break' && rest -title 'Work Timer is up! Take a Break π' -appIcon '/Pictures/tomato.png' -sound Crystal"/Pictures/tomato.png' -sound Crystal"
alias rest="timer 10s && terminal-notifier -message 'Break is over! Get back to work' && work -title 'Break is over! Get back to work π¬' -appIcon 'Hey i just made a function:
pomo(){ echo "How many rounds you want to do?" read count; for i in {1..$count}; do work; sleep 1; rest; donehope it solves your problem. just type the function name in the terminal: here -> pomo Oh, and put the code under the two alias!
It worked!
Can you edit the code because it needs a closing bracket. Maybe others will face the problem if you don't edit it
Thank You!
I like this configuration π try it
firstly install tool
brew install terminal-notifier
brew install caarlos0/tap/timer
Mac setup for pomodoro
add alias in your ".zshrc" file
alias work="timer 60m && say 'Mola verme zamanΔ± dostum! Kalk ve biraz yΓΌrΓΌyΓΌΕe Γ§Δ±k! Biraz su iΓ§!' \
&& terminal-notifier -message 'Pomodoro'\
-title 'Work Timer is up! Take a Break π'\
-appIcon 'http://vjeantet.fr/images/logo.png' \
-sound Crystal"
alias rest="timer 10m && say 'Mola bitti, hadi ders Γ§alΔ±Εma zamanΔ±' \
&& terminal-notifier -message 'Pomodoro'\
-title 'Break is over! Get back to work π¬'\
-appIcon 'http://vjeantet.fr/images/logo.png' \
-sound Crystal"
then call on your terminal like "work" or "rest"
This is great! How can I make this auto start work and auto start rest?
I test using this code. When I runwork
command, the terminal auto executerest
command. But after the rest timer is up, thework
command isn't execute. Vice versa when I runrest
command first.
alias work="timer 5s && terminal-notifier -message 'Timer is up! Take a Break' && rest -title 'Work Timer is up! Take a Break π' -appIcon '/Pictures/tomato.png' -sound Crystal"/Pictures/tomato.png' -sound Crystal"
alias rest="timer 10s && terminal-notifier -message 'Break is over! Get back to work' && work -title 'Break is over! Get back to work π¬' -appIcon 'Hey i just made a function:
pomo(){ echo "How many rounds you want to do?" read count; for i in {1..$count}; do work; sleep 1; rest; done }hope it solves your problem. just type the function name in the terminal: here -> pomo Oh, and put the code under the two alias!
*Thanks at @nayakayp for finding the lost bracket π
Thank you so much for this, it's just what I needed!
I managed to get the script working, but at the end of the timer, the notification does not show up. I've installed the terminal-notifier using homebrew, but it doesn't appear to be show up. The timer just counts down and displays "finished" on the terminal. Any suggestions on how to fix this?
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
Oh I overlooked that! Thank you for the help!
Also check that macOS is allowing terminal-notifier
to run. At first when I ran terminal-notifier
from iTerm 2, it wouldn't create notifications. I'm not sure exactly how I got it to show notifications but I think I first got it to run in Terminal, and then notifications worked when I ran the command from iTerm 2.
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
I'm running into the same problem but I have checked that Notifications have been enabled for terminal-notifier...anything else that could be causing this?
@kimmy2611 go to Systems Preferences > Notifications > then make sure that terminal-notifier is allowed to send notifications with sounds, banners, etc
I'm running into the same problem but I have checked that Notifications have been enabled for terminal-notifier...anything else that could be causing this?
It's a mess. My weird fix was to install via brew (wasn't working correctly like yours even with Notifications enabled), download the binary from the repo and put the app in Applications - which triggered it to work. Then I brew uninstalled it, removed the app, and reinstalled again, now it works .... Made sure the Notifications are enabled after all that - macos might do a banner pop up for you to enable it.
Super helpful, thanks for posting this.
If it's helpful to anyone, I edited the alias to instead run as a bash script so we can turn on/off focus mode easily, including turning it off when exiting the program early. I also added a time arg but it defaults to whatever you time you write in the script (25m and 5m below):
#!/bin/bash
# Function for work mode
work() {
local duration=${1:-25m} # Default to 5 minutes if no argument is provided
macos-focus-mode enable
timer "$duration"
macos-focus-mode disable
osascript -e 'display notification "β" with title "Work Timer is up!" subtitle "Take a Break π" sound name "Crystal"'
}
# Function for rest mode
rest() {
local duration=${1:-5m} # Default to 10 minutes if no argument is provided
timer "$duration"
osascript -e 'display notification "β" with title "Break is over" subtitle "Back to work, loser δ·" sound name "Crystal"'
}
# Trap to disable focus mode when script exits
trap 'macos-focus-mode disable' EXIT
# Main script logic
case "$1" in
work)
work "$2"
;;
rest)
rest "$2"
;;
*)
echo "Usage: $0 {work|rest} [time]"
exit 1
;;
esac
You don't need to install
terminal-notifier
if you don't want to. You can trigger notifications on osx with applescriptosascript -e 'display notification "β" with title "Work Timer is up!" subtitle "Take a Break π" sound name "Crystal"'
but how would i combine this with the alias, cause then there are 3 layers of strings?
You don't need to install
terminal-notifier
if you don't want to. You can trigger notifications on osx with applescriptosascript -e 'display notification "β" with title "Work Timer is up!" subtitle "Take a Break π" sound name "Crystal"'
but how would i combine this with the alias, cause then there are 3 layers of strings?
ok you would have to escape it like this: " -> so in the rc-file it would look like this:
alias work="timer 50m && osascript -e 'display notification \"β\" with title \"Work Timer is up!\" subtitle \"Take a Break π\" sound name \"Crystal\"'"
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\""
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
I'm getting an error
zsh: command not found: timer
(( I'm thinking that some package is missing but couldn't find one