Context
I'm trying to build a dialog box feeded with my timewarrior data, so I can directly select what I'm going back to rather than timew s :ids filter_tag
, then time cont @12
.
So, first I created the data set that is attempted to populate the Dialog options:
timew s :ids $(date -I -d'8 days ago') - $(date -I -d'tomorrow') |
# most recent first, only the top 30 (4 additional lines are decoration)
tac | head -n 34 |
# format the whole thing as '1 "some label "' and so on
sed -ne 's:.*@::p' |
sed -e 's|\s\+[0-9]\+:.*| |g' -e's:\s\+: ":' -e's:\s*$:":' -e's:^: :'
This generates reports like the following:
1 "some_info, some_info"
2 "some_info, some_info"
3 "some_info, some_info"
4 "some_info"
5 "some_info, some_info"
6 "some_info, some_info, some_info"
7 "some_info, some_info"
8 "some_info, some_info-some_info, some_info, some_info"
9 "some_info, some_info"
10 "some_info, some_info-some_info, some_info, some_info"
11 "some_info, some_info"
12 "some_info, some_info"
13 "some_info"
14 "some_info, some_info"
14 "some_info, some_info"
15 "some_info, some_info, some_info"
16 "some_info, some_info, some_info, some_info, some_info, some_info"
17 "some_info, some_info, some_info"
18 "some_info"
19 "some_info, some_info"
20 "some_info"
21 "some_info, some_info, some_info, some_info, some_info, some_info"
22 "some_info, some_info"
23 "some_info, some_info, some_info, some_info, some_info, some_info"
24 "some_info, some_info45, some_info some_info some_info, some_info"
25 "some_info"
26 "some_info"
27 "some_info, some_info, some_info"
28 "some_info, some_info, some_info, some_info"
29 "some_info, some_info, some_info"
30 "some_info"
The Dialog scaffold
So I found this scaffold to
#!/bin/bash
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
BACKTITLE="Backtitle here"
TITLE="Title here"
MENU="Choose one of the following options:"
OPTIONS=(1 "Option 1"
2 "Option 2"
3 "Option 3")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
1)
echo "You chose Option 1"
;;
2)
echo "You chose Option 2"
;;
3)
echo "You chose Option 3"
;;
esac
Issue
So I naively thought that using OPTIONS=( $(timew s :ids $(date -I -d'8 days ago') - $(date -I -d'tomorrow') | tac | head -n 34 | sed -ne 's:.*@::p' | sed -e 's|\s\+[0-9]\+:.*| |g' -e's:\s\+: ":' -e's:\s*$:":'))
as a replacement in the previous code would do the trick. But it seems that quotes won't be taken into consideration so easily. I tried to hack that around in various ways, including in a while read
loop and using Shell parameter expansion: ${variable@Q}, and other horrifying stuffs, but didn't found anything that would work.
Question
How do I populate correctly the Dialog options with the output of my Timewarrior output?