Skip to content

Instantly share code, notes, and snippets.

@bashbunni
Last active December 4, 2025 17:32
Show Gist options
  • Select an option

  • Save bashbunni/3880e4194e3f800c4c494de286ebc1d7 to your computer and use it in GitHub Desktop.

Select an option

Save bashbunni/3880e4194e3f800c4c494de286ebc1d7 to your computer and use it in GitHub Desktop.
CLI Pomodoro for Linux (zsh)
# study stream aliases
# Requires https://github.com/caarlos0/timer to be installed. spd-say should ship with your distro
declare -A pomo_options
pomo_options["work"]="45"
pomo_options["break"]="10"
pomodoro () {
if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
val=$1
echo $val | lolcat
timer ${pomo_options["$val"]}m
spd-say "'$val' session done"
fi
}
alias wo="pomodoro 'work'"
alias br="pomodoro 'break'"
@junaid10144
Copy link

junaid10144 commented Jul 26, 2025

To use your .zshrc and the pomodoro function on WSL with Ubuntu 24.04, follow these steps:


✅ 1. Install Required Tools

Before using your aliases and functions, install the required tools in your WSL environment:

sudo apt update
sudo apt install zsh lolcat espeak  # spd-say comes from speech-dispatcher or use espeak as fallback

Then install timer from GitHub (by caarlos0):

# Install Go (required for building the timer)
sudo apt install golang-go

# Clone and install the timer tool
git clone https://github.com/caarlos0/timer.git
cd timer
go build -o timer
sudo mv timer /usr/local/bin/

Now timer should be available system-wide.


✅ 2. Ensure You're Using zsh in WSL

If you're not already using Zsh as your shell in WSL, switch to it:

sudo apt install zsh
chsh -s $(which zsh)

Then restart WSL or run zsh.


✅ 3. Configure .zshrc

Put your function and aliases in the .zshrc file:

nano ~/.zshrc

Paste this:

# study stream aliases
# Requires https://github.com/caarlos0/timer to be installed. spd-say should ship with your distro

declare -A pomo_options
pomo_options["work"]="45"
pomo_options["break"]="10"

pomodoro () {
  if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
  val=$1
  echo $val | lolcat
  timer ${pomo_options["$val"]}m
  spd-say "'$val' session done"
  fi
}

alias wo="pomodoro 'work'"
alias br="pomodoro 'break'"

Then reload it:

source ~/.zshrc

✅ 4. Run the Commands

Now you can simply run:

wo   # starts a 45-minute "work" timer
br   # starts a 10-minute "break" timer

⚠️ Note on spd-say in WSL

spd-say may not produce audio output in WSL directly unless you have audio forwarding set up (via PulseAudio or similar). If it doesn't work, consider replacing spd-say with something like espeak or even just a notify-send (if running a Linux GUI).

Example:

espeak "'$val' session done"

or remove it if sound isn’t essential.


✅ How to Send Windows Notifications from WSL

The only way to get native Windows notifications from WSL is to explicitly call Windows tools from WSL, like PowerShell.

✔️ Step-by-Step: Add Windows Toast Notification

🔧 1. Install the BurntToast module (Windows side)

In a Windows PowerShell terminal (not WSL), run:

Install-Module -Name BurntToast -Force -SkipPublisherCheck

You only need to do this once. BurntToast is a PowerShell module for sending toast notifications.


✏️ 2. Modify Your pomodoro Function

Update your function to use PowerShell from WSL to send a toast:

pomodoro () {
  if [ -n "$1" ] && [ -n "${pomo_options["$1"]}" ]; then
    val=$1
    echo $val | lolcat
    timer ${pomo_options["$val"]}m
    espeak "'$val' session done"
    powershell.exe -Command "New-BurntToastNotification -Text 'Pomodoro Timer', '$val session done'" > /dev/null 2>&1
  fi
}

This line:

powershell.exe -Command "New-BurntToastNotification -Text 'Pomodoro Timer', '$val session done'"

runs PowerShell on Windows from WSL, and sends the notification natively.


🧪 3. Test It

After timer finishes, you should:

  • ✅ Hear audio (espeak)
  • ✅ See a Windows toast notification pop up

@nameerakhter
Copy link

for anyone trying to use this on windows you can add this function to your powershell profile

# --- The Main Function ---
function Start-PomoTimer {
    param (
        [string]$TimerType
    )

    $pomoOptions = @{
        "work"  = "50m"
        "break" = "10m"
        "short" = "5m"
    }

    # --- REMEMBER TO UPDATE THE PATH OF THE CLONED REPOSITORY HERE ---
    $timerPath = "D:\timer\timer.exe"

    if ($pomoOptions.ContainsKey($TimerType)) {
        $duration = $pomoOptions[$TimerType]
        Write-Host "Starting '$TimerType' timer for $duration..."
        & $timerPath $duration -n $TimerType
        Write-Host "'$TimerType' session done!"
    } else {
        Write-Host "Invalid timer type: '$TimerType'. Available types: $($pomoOptions.Keys -join ', ')"
    }
}

function Start-PomoWork {
    Start-PomoTimer -TimerType "work"
}

function Start-PomoBreak {
    Start-PomoTimer -TimerType "break"
}


# --- Updated Aliases pointing to the new functions ---
Set-Alias -Name wo -Value Start-PomoWork
Set-Alias -Name br -Value Start-PomoBreak

@mohsince-04
Copy link

Check out my setup in this repo — fish-flowmodoro, a simple Fish Shell productivity timer with chill audio cues.

@jonahmondragon
Copy link

Thanks Bash, love you.

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