#!/usr/bin/env bash # # Timewarrior tag renamer. # # Parameters BASENAME="`basename $0`" OLD="$1" NEW="$2" # Rename tag: use as timew-tagrename # 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 " exit 1 fi # Dispatch timew_tagrename $OLD $NEW