some initial previewk lots ofs fixes
This commit is contained in:
68
src/main.sh
68
src/main.sh
@@ -83,6 +83,13 @@ EOF
|
||||
AWK_DAYVIEW=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/dayview.awk
|
||||
EOF
|
||||
)
|
||||
export AWK_DAYVIEW
|
||||
|
||||
AWK_PREVIEW=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/preview.awk
|
||||
EOF
|
||||
)
|
||||
export AWK_DAYVIEW
|
||||
@@ -129,38 +136,38 @@ __show_day() {
|
||||
shift
|
||||
endtime="$1"
|
||||
shift
|
||||
fpath="$1"
|
||||
fpath="$(echo "$1" | sed 's/|/ /g')" # we will use | as delimiter (need to convert back!)
|
||||
shift
|
||||
description=$(echo "$*" | sed 's/|/:/g') # we will use | as delimiter
|
||||
description="$(echo "$*" | sed 's/|/:/g')" # we will use | as delimiter
|
||||
#
|
||||
daystart=$(date -d "$today 00:00:00" +"%s")
|
||||
dayend=$(date -d "$today 23:59:59" +"%s")
|
||||
line=""
|
||||
if [ "$starttime" -gt "$daystart" ] && [ "$starttime" -lt "$dayend" ]; then
|
||||
s=$(date -d "@$starttime" +"%H:%M")
|
||||
s=$(date -d "@$starttime" +"%R")
|
||||
elif [ "$starttime" -le "$daystart" ] && [ "$endtime" -gt "$daystart" ]; then
|
||||
s="00:00"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
if [ "$endtime" -gt "$daystart" ] && [ "$endtime" -lt "$dayend" ]; then
|
||||
e=$(date -d "@$endtime" +"%H:%M")
|
||||
e=$(date -d "@$endtime" +"%R")
|
||||
elif [ "$endtime" -ge "$dayend" ] && [ "$starttime" -lt "$dayend" ]; then
|
||||
e="00:00"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
echo "$s|$e|$fpath|$description"
|
||||
echo "$s|$e|$starttime|$endtime|$fpath|$description"
|
||||
done)
|
||||
fi
|
||||
GREEN="\033[1;32m"
|
||||
OFF="\033[m"
|
||||
echo "|🗓️ $GREEN $(date -d "$DISPLAY_DATE" +"%a %e %b %Y")$OFF"
|
||||
echo "||||🗓️ $GREEN $(date -d "$DISPLAY_DATE" +"%a %e %b %Y")$OFF"
|
||||
echo ""
|
||||
(
|
||||
echo "$sef"
|
||||
seq 8 18 | sort -n
|
||||
) | awk "$AWK_DAYVIEW"
|
||||
seq 8 18
|
||||
) | sort -n | awk "$AWK_DAYVIEW"
|
||||
}
|
||||
|
||||
__list() {
|
||||
@@ -233,6 +240,32 @@ if [ -z "${WEEKLY_DATA_FILE:-}" ]; then
|
||||
export WEEKLY_DATA_FILE
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--preview" ]; then
|
||||
hour=$(echo "$2" | cut -d '|' -f 1)
|
||||
start=$(echo "$2" | cut -d '|' -f 2)
|
||||
end=$(echo "$2" | cut -d '|' -f 3)
|
||||
fpath=$(echo "$2" | cut -d '|' -f 4 | sed "s/ /|/g")
|
||||
if [ -n "$hour" ] && [ -n "$fpath" ]; then
|
||||
fpath="$ROOT/$fpath"
|
||||
timestart=$(date -d "@$start" +"%R")
|
||||
timeend=$(date -d "@$end" +"%R")
|
||||
dfmt="%a %e %b %Y"
|
||||
if [ "$timestart" != "00:00" ]; then
|
||||
dfmt="$dfmt %Y %R %Z"
|
||||
fi
|
||||
start=$(date -d "@$start" +"$dfmt")
|
||||
dfmt="%a %e %b %Y"
|
||||
if [ "$timeend" != "00:00" ]; then
|
||||
dfmt="$dfmt %Y %R %Z"
|
||||
fi
|
||||
end=$(date -d "@$end" +"$dfmt")
|
||||
echo "START @ $start, END @ $end"
|
||||
fi
|
||||
#awk -v field="DESCRIPTION" "$AWK_PREVIEW" "$fpath" |
|
||||
# $CAT
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--day" ]; then
|
||||
DISPLAY_DATE="$2"
|
||||
echo "Jumping to day $DISPLAY_DATE!"
|
||||
@@ -244,13 +277,22 @@ if [ "${1:-}" = "--day" ]; then
|
||||
--no-sort \
|
||||
--no-input \
|
||||
--delimiter='|' \
|
||||
--with-nth='{2}' \
|
||||
--accept-nth='{1}' \
|
||||
--with-nth='{5}' \
|
||||
--accept-nth='1,2,3,4' \
|
||||
--preview="$0 --preview {}" \
|
||||
--bind="backspace:first+accept"
|
||||
)
|
||||
if [ -n "$selection" ]; then
|
||||
fpath="$ROOT/$selection"
|
||||
fi
|
||||
hour=$(echo "$selection" | cut -d '|' -f 1)
|
||||
start=$(echo "$selection" | cut -d '|' -f 2)
|
||||
end=$(echo "$selection" | cut -d '|' -f 3)
|
||||
fpath=$(echo "$selection" | cut -d '|' -f 4 | sed "s/ /|/g")
|
||||
if [ -n "$fpath" ]; then
|
||||
fpath="$ROOT/$fpath"
|
||||
# TODO: Go on edit file
|
||||
elif [ -n "$hour" ]; then
|
||||
# TODO Go on add entry for hour
|
||||
echo "Add entry for hour $hour"
|
||||
fi # Else: continue
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--date" ]; then
|
||||
|
Reference in New Issue
Block a user