Add timewarrior import script
This commit is contained in:
parent
eebe6c4d43
commit
b586e13a98
1 changed files with 29 additions and 0 deletions
29
bin/domain/imag-timetrack/etc/timew-import.sh
Normal file
29
bin/domain/imag-timetrack/etc/timew-import.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# timewarrior import script
|
||||
#
|
||||
# pipe `timew export` to this script for importing timew data into imag.
|
||||
#
|
||||
# Requirements for running this script:
|
||||
# - imag
|
||||
# - imag-timetrack
|
||||
# - sed
|
||||
# - jq
|
||||
#
|
||||
|
||||
# This might be hacky, but it works.
|
||||
|
||||
fixtimeformat() {
|
||||
sed -E 's/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z/\1-\2-\3T\4:\5:\6/'
|
||||
}
|
||||
|
||||
tail -n +2 | head -n -2 | while read line; do
|
||||
json=$(echo "$line" | sed 's/,$//')
|
||||
start=$(echo "$json" | jq '.start' | fixtimeformat | sed 's/"//g' )
|
||||
end=$(echo "$json" | jq '.end' | fixtimeformat | sed 's/"//g' )
|
||||
tags=$(echo "$json" | jq '.tags' | grep "\"" | sed 's/,//; s/"//g')
|
||||
|
||||
echo imag timetrack track "$start" "$end" $tags
|
||||
imag timetrack track "$start" "$end" $tags
|
||||
done
|
||||
|
Loading…
Reference in a new issue