-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e84c83
commit be61450
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env nu | ||
|
||
# Start and view status of tomato timers | ||
def main [ | ||
-t | ||
-l | ||
-b | ||
-s | ||
] { | ||
if $t { | ||
start-tomato | ||
} else if $b { | ||
start-short-break | ||
} else if $l { | ||
start-long-break | ||
} | ||
if $s { | ||
time-left | ||
} | ||
} | ||
|
||
def start-tomato [] { | ||
(date now) + 25min | ||
| save -f (filepath) | ||
} | ||
|
||
def start-short-break [] { | ||
(date now) + 5min | ||
| save -f (filepath) | ||
} | ||
|
||
def start-long-break [] { | ||
(date now) + 15min | ||
| save -f (filepath) | ||
} | ||
|
||
def time-left [] { | ||
open (filepath) | ||
| into datetime | ||
| $in - (date now) | ||
| if $in < 0min { | ||
"Done" | ||
} else { | ||
format duration min | ||
} | ||
} | ||
|
||
def filepath [] { | ||
"~/.pomodoro" | ||
| path expand | ||
} | ||
|
||
def error [msg] { | ||
print $"(ansi red)($msg)(ansi reset)" | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters