todos: make todos script

This commit is contained in:
Daniella / Tove 2024-11-03 00:08:06 +01:00
parent 34eaaa25e5
commit 2aaefc23f1
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
4 changed files with 43 additions and 27 deletions

View file

@ -49,6 +49,8 @@ in
#marker.pkgs.end#
(import ./traewelling.script.nix)
(import ./plans.script.nix)
(import ./todos.script.nix)
(import ./plans-backend.script.nix)
] ++ (with pkgs; [
freecad
nheko

33
plans-backend.script.nix Normal file
View file

@ -0,0 +1,33 @@
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
''

View file

@ -2,32 +2,6 @@ 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 - 1)) ~/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
file=~/sync/plans.txt plans-backend $@
''

7
todos.script.nix Normal file
View file

@ -0,0 +1,7 @@
with import <nixpkgs> {};
pkgs.writeShellScriptBin "todos" ''
#!/bin/sh
file=~/sync/todos.txt plans-backend $@
''