From 2aaefc23f10c7d9ed6bfb16f31c01b1d468b8e7a Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sun, 3 Nov 2024 00:08:06 +0100 Subject: [PATCH] todos: make todos script --- home.nix | 2 ++ plans-backend.script.nix | 33 +++++++++++++++++++++++++++++++++ plans.script.nix | 28 +--------------------------- todos.script.nix | 7 +++++++ 4 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 plans-backend.script.nix create mode 100644 todos.script.nix diff --git a/home.nix b/home.nix index 56cd247..b46f2e4 100644 --- a/home.nix +++ b/home.nix @@ -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 diff --git a/plans-backend.script.nix b/plans-backend.script.nix new file mode 100644 index 0000000..6e9ce82 --- /dev/null +++ b/plans-backend.script.nix @@ -0,0 +1,33 @@ +with import {}; + +pkgs.writeShellScriptBin "plans-backend" '' + #!/bin/sh + if [ "$1" = "help" ] ; then + echo "plans (tudbut)" + echo + echo "- add -- 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 +'' + diff --git a/plans.script.nix b/plans.script.nix index b4d9ac0..ea9d685 100644 --- a/plans.script.nix +++ b/plans.script.nix @@ -2,32 +2,6 @@ with import {}; pkgs.writeShellScriptBin "plans" '' #!/bin/sh - if [ "$1" = "help" ] ; then - echo "plans (tudbut)" - echo - echo "- add -- 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 $@ '' diff --git a/todos.script.nix b/todos.script.nix new file mode 100644 index 0000000..ae555a4 --- /dev/null +++ b/todos.script.nix @@ -0,0 +1,7 @@ +with import {}; + +pkgs.writeShellScriptBin "todos" '' + #!/bin/sh + file=~/sync/todos.txt plans-backend $@ +'' +