aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-11-11 14:23:45 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-11-11 14:23:45 -0300
commit1af2d38b7a75f6295bea3b0c71802afe826f2afb (patch)
treecce6903899b846acc66434d2b96132bd8468c8a7
parent3c5c672e47737e6b3342dfeb730ccd8320f2d442 (diff)
downloadutils-organization-1af2d38b7a75f6295bea3b0c71802afe826f2afb.tar.gz
utils-organization-1af2d38b7a75f6295bea3b0c71802afe826f2afb.tar.bz2
Feat: adds timew-tagrename
-rwxr-xr-xtimew-tagrename29
1 files changed, 29 insertions, 0 deletions
diff --git a/timew-tagrename b/timew-tagrename
new file mode 100755
index 0000000..06edd98
--- /dev/null
+++ b/timew-tagrename
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#
+# Timewarrior tag renames.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+OLD="$1"
+NEW="$2"
+
+# Rename tag: use as timew-tagrename <oldtag> <newtag>
+# Based on from https://github.com/GothenburgBitFactory/timewarrior/issues/210
+function timew_tagrename() {
+ oldtag="$1"
+ newtag="$2"
+ idlist="$(timew summary 1970W01 - now "$oldtag" :ids | sed -nr 's/.* (@[0-9]+) .*/\1/p')"
+
+ timew tag $idlist "$newtag"
+ timew untag $idlist "$oldtag"
+}
+
+# Check
+if [ -z "$NEW" ]; then
+ echo "usage: $BASENAME <old-tag> <new-tag>"
+ exit 1
+fi
+
+# Dispatch
+timew_tagrename $OLD $NEW