nix-setup/plans-backend.script.nix

34 lines
744 B
Nix
Raw Permalink Normal View History

2024-11-03 00:08:06 +01:00
with import <nixpkgs> {};
pkgs.writeShellScriptBin "plans-backend" ''
#!/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 $file"
exit
fi
if [ "$1" = "add" ] ; then
echo "- $2" >> $file
fi
if [ "$1" = "done" ] ; then
if [ "$2" != "" ] ; then
head -n $(($2 - 1)) $file > ~/plans.txt.tmp
tail -n"$(($(wc -l < $file) - $2))" $file >> ~/plans.txt.tmp
else
tail -n"$(($(wc -l < $file) - 1))" $file > ~/plans.txt.tmp
fi
mv ~/plans.txt.tmp $file
fi
if [ "$1" = "edit" ] ; then
hx $file
fi
cat -n $file
''