nix-config/packages/todos-add.nix
Oliver Davies 5341b761ad
All checks were successful
/ check (push) Successful in 1m40s
Combine scripts and custom packages
2025-07-10 22:51:55 +01:00

21 lines
430 B
Nix
Executable file

{ pkgs }:
pkgs.writeShellApplication {
name = "todos-add";
runtimeInputs = with pkgs; [ coreutils ];
text = ''
TODOS_PATH="$HOME/Documents/wiki/todo.txt"
if [ ''${#} -eq 0 ]; then
if [ -p "/dev/stdin" ]; then
(cat; printf "\n\n") >> "''${TODOS_PATH}"
else
eval "''${TODOS_EDITOR}" "''${TODOS_PATH}"
fi
else
printf "%s\n\n" "''${*}" >> "''${TODOS_PATH}"
fi
'';
}