nix-setup/plans.script.nix
2024-10-31 17:43:14 +01:00

33 lines
837 B
Nix

with import <nixpkgs> {};
pkgs.writeShellScriptBin "plans" ''
#!/bin/sh
if [ "$1" = "help" ] ; then
echo "plans (tudbut)"
echo
echo "- add <str> -- add to end of list"
echo "- done [n] -- remove from list"
echo "- edit -- edit manually using helix"
echo "default prints list"
echo
echo "file used is ~/sync/plans.txt"
exit
fi
if [ "$1" = "add" ] ; then
echo "- $2" >> ~/sync/plans.txt
fi
if [ "$1" = "done" ] ; then
if [ "$2" != "" ] ; then
head -n $2 ~/sync/plans.txt > ~/plans.txt.tmp
tail -n"$(($(wc -l < ~/sync/plans.txt) - $2))" ~/sync/plans.txt >> ~/plans.txt.tmp
else
tail -n"$(($(wc -l < ~/sync/plans.txt) - 1))" ~/sync/plans.txt > ~/plans.txt.tmp
fi
mv ~/plans.txt.tmp ~/sync/plans.txt
fi
if [ "$1" = "edit" ] ; then
hx ~/sync/plans.txt
fi
cat -n ~/sync/plans.txt
''