From ad2a47d42b675d4e5181dd9dad21e66e52f7b34e Mon Sep 17 00:00:00 2001 From: TudbuT Date: Thu, 31 Oct 2024 17:39:26 +0100 Subject: [PATCH] plans: improve done cmd --- plans.script.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plans.script.nix b/plans.script.nix index a0a7122..a63d43a 100644 --- a/plans.script.nix +++ b/plans.script.nix @@ -6,8 +6,9 @@ pkgs.writeShellScriptBin "plans" '' echo "plans (tudbut)" echo echo "- add -- add to end of list" - echo "- done -- remove from start 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 @@ -16,12 +17,17 @@ pkgs.writeShellScriptBin "plans" '' echo "- $2" >> ~/sync/plans.txt fi if [ "$1" = "done" ] ; then - tail -n"$(($(wc -l < ~/sync/plans.txt) - 1))" ~/sync/plans.txt > ~/plans.txt.tmp + 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 ~/sync/plans.txt + cat -n ~/sync/plans.txt ''