aboutsummaryrefslogtreecommitdiff
path: root/timew-tagrename
diff options
context:
space:
mode:
Diffstat (limited to '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