Skip to content

Instantly share code, notes, and snippets.

@bashbunni
Created January 4, 2023 16:28
Show Gist options
  • Save bashbunni/3880e4194e3f800c4c494de286ebc1d7 to your computer and use it in GitHub Desktop.
Save bashbunni/3880e4194e3f800c4c494de286ebc1d7 to your computer and use it in GitHub Desktop.
CLI Pomodoro for Linux
# 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'"
@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

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