added expect

This commit is contained in:
Ämin Baumeler 2025-06-10 13:56:27 +02:00
parent cf19b724ea
commit c7f5082671

View File

@ -348,20 +348,22 @@ if [ "${1:-}" = "--day" ]; then
--with-nth='{5}' \ --with-nth='{5}' \
--accept-nth='1,2,3,4' \ --accept-nth='1,2,3,4' \
--preview="$0 --preview {}" \ --preview="$0 --preview {}" \
--bind="backspace:first+accept" \ --expect="ctrl-n" \
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" --bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)"
) )
hour=$(echo "$selection" | cut -d '|' -f 1) key=$(echo "$selection" | head -1)
start=$(echo "$selection" | cut -d '|' -f 2) line=$(echo "$selection" | tail -1)
end=$(echo "$selection" | cut -d '|' -f 3) hour=$(echo "$line" | cut -d '|' -f 1)
fpath=$(echo "$selection" | cut -d '|' -f 4 | sed "s/ /|/g") start=$(echo "$line" | cut -d '|' -f 2)
if [ -n "$fpath" ]; then end=$(echo "$line" | cut -d '|' -f 3)
fpath="$ROOT/$fpath" fpath=$(echo "$line" | cut -d '|' -f 4 | sed "s/ /|/g")
__edit "$start" "$end" "$fpath" if [ "$key" = "ctrl-n" ]; then
elif [ -n "$hour" ]; then
# TODO: Go on add entry for hour # TODO: Go on add entry for hour
echo "Add entry for hour $hour" echo "Add entry for hour $hour"
fi # Else: continue elif [ -n "$fpath" ]; then
fpath="$ROOT/$fpath"
__edit "$start" "$end" "$fpath"
fi
fi fi
if [ "${1:-}" = "--date" ]; then if [ "${1:-}" = "--date" ]; then
@ -375,37 +377,47 @@ DISPLAY_DATE_NEXT=$(date -d "$DISPLAY_DATE +1 week" +"%D")
DISPLAY_DATE_PREV_MONTH=$(date -d "$DISPLAY_DATE -1 month" +"%D") DISPLAY_DATE_PREV_MONTH=$(date -d "$DISPLAY_DATE -1 month" +"%D")
DISPLAY_DATE_NEXT_MONTH=$(date -d "$DISPLAY_DATE +1 month" +"%D") DISPLAY_DATE_NEXT_MONTH=$(date -d "$DISPLAY_DATE +1 month" +"%D")
selection=$( ( selection=$(
cat "$APPROX_DATA_FILE" (
yes " " | head -n 50 cat "$APPROX_DATA_FILE"
__list yes " " | head -n 50
) | __list
$FZF \ ) |
--tac \ $FZF \
--no-sort \ --tac \
--no-hscroll \ --no-sort \
--ellipsis='' \ --no-hscroll \
--delimiter='|' \ --ellipsis='' \
--with-nth='{4}' \ --delimiter='|' \
--accept-nth=1,2 \ --with-nth='{4}' \
--no-info \ --accept-nth=1,2 \
--ansi \ --no-info \
--no-clear \ --ansi \
--no-scrollbar \ --no-clear \
--bind="load:pos($DISPLAY_POS)" \ --no-scrollbar \
--bind="ctrl-u:become($0 --date '$DISPLAY_DATE_PREV')" \ --expect="ctrl-n" \
--bind="ctrl-d:become($0 --date '$DISPLAY_DATE_NEXT')" \ --bind="load:pos($DISPLAY_POS)" \
--bind="ctrl-alt-u:become($0 --date '$DISPLAY_DATE_PREV_MONTH')" \ --bind="ctrl-u:become($0 --date '$DISPLAY_DATE_PREV')" \
--bind="ctrl-alt-d:become($0 --date '$DISPLAY_DATE_NEXT_MONTH')" \ --bind="ctrl-d:become($0 --date '$DISPLAY_DATE_NEXT')" \
--bind="ctrl-l:become($0)") --bind="ctrl-alt-u:become($0 --date '$DISPLAY_DATE_PREV_MONTH')" \
--bind="ctrl-alt-d:become($0 --date '$DISPLAY_DATE_NEXT_MONTH')" \
--bind="ctrl-l:become($0)"
)
if [ -z "$selection" ]; then key=$(echo "$selection" | head -1)
line=$(echo "$selection" | tail -1)
sign=$(echo "$line" | cut -d '|' -f 1)
startdate=$(echo "$line" | cut -d '|' -f 2)
if [ "$key" = "ctrl-n" ]; then
# Add new
echo "NOT IMPLEMENTED: Add wrt $line"
exit
fi
if [ -z "$key" ] && [ -z "$line" ]; then
rm "$WEEKLY_DATA_FILE" "$APPROX_DATA_FILE" rm "$WEEKLY_DATA_FILE" "$APPROX_DATA_FILE"
return 0 return 0
fi fi
sign=$(echo "$selection" | cut -d '|' -f 1)
startdate=$(echo "$selection" | cut -d '|' -f 2)
if [ "$sign" = "~" ]; then if [ "$sign" = "~" ]; then
exec $0 --date "$startdate" exec $0 --date "$startdate"
else else