This commit is contained in:
parent
263d8e7cd3
commit
3c76e2edea
4 changed files with 30 additions and 0 deletions
|
@ -40,6 +40,7 @@
|
|||
home.packages = with pkgs; [
|
||||
create-script
|
||||
tag-release
|
||||
time-until
|
||||
todos-add
|
||||
update-all-git-repos
|
||||
];
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
move-firefox-screenshots
|
||||
setbg
|
||||
tag-release
|
||||
time-until
|
||||
timer
|
||||
todos-add
|
||||
unmounter
|
||||
|
|
|
@ -18,6 +18,7 @@ in
|
|||
passmenu-otp = callPackage ./passmenu-otp.nix { };
|
||||
setbg = callPackage ./setbg.nix { };
|
||||
tag-release = callPackage ./tag-release.nix { };
|
||||
time-until = callPackage ./time-until.nix { };
|
||||
timer = callPackage ./timer.nix { };
|
||||
tmux-sessionizer = callPackage ./tmux-sessionizer { };
|
||||
todos-add = callPackage ./todos-add.nix { };
|
||||
|
|
27
packages/time-until.nix
Normal file
27
packages/time-until.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "time-until";
|
||||
|
||||
runtimeInputs = with pkgs; [ bc ];
|
||||
|
||||
text = ''
|
||||
# Based on https://github.com/sdaschner/dotfiles/blob/master/bin/time-until.
|
||||
set +o nounset
|
||||
|
||||
if [[ "$1" == "" ]]; then
|
||||
echo "Usage: ''${0##*/} <date-string>"
|
||||
echo " Example: ''${0##*/} 'tomorrow 06:00'"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
set -o nounset
|
||||
|
||||
secsUntil=$(( $(date +%s -d "$*") - $( date +%s ) ))
|
||||
minutesUntil=$(bc <<< "scale=1; $secsUntil/60")
|
||||
hoursUntil=$(bc <<< "scale=2; $secsUntil/3600")
|
||||
date=$(date -d "$*")
|
||||
|
||||
echo "$hoursUntil hours (or $minutesUntil mins) until $date"
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue