todos: make todos script
This commit is contained in:
parent
34eaaa25e5
commit
2aaefc23f1
4 changed files with 43 additions and 27 deletions
2
home.nix
2
home.nix
|
@ -49,6 +49,8 @@ in
|
||||||
#marker.pkgs.end#
|
#marker.pkgs.end#
|
||||||
(import ./traewelling.script.nix)
|
(import ./traewelling.script.nix)
|
||||||
(import ./plans.script.nix)
|
(import ./plans.script.nix)
|
||||||
|
(import ./todos.script.nix)
|
||||||
|
(import ./plans-backend.script.nix)
|
||||||
] ++ (with pkgs; [
|
] ++ (with pkgs; [
|
||||||
freecad
|
freecad
|
||||||
nheko
|
nheko
|
||||||
|
|
33
plans-backend.script.nix
Normal file
33
plans-backend.script.nix
Normal 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
|
||||||
|
''
|
||||||
|
|
|
@ -2,32 +2,6 @@ with import <nixpkgs> {};
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "plans" ''
|
pkgs.writeShellScriptBin "plans" ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if [ "$1" = "help" ] ; then
|
file=~/sync/plans.txt plans-backend $@
|
||||||
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
|
|
||||||
''
|
''
|
||||||
|
|
||||||
|
|
7
todos.script.nix
Normal file
7
todos.script.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
pkgs.writeShellScriptBin "todos" ''
|
||||||
|
#!/bin/sh
|
||||||
|
file=~/sync/todos.txt plans-backend $@
|
||||||
|
''
|
||||||
|
|
Loading…
Add table
Reference in a new issue