goto functionality

This commit is contained in:
Ämin Baumeler 2025-06-11 10:03:04 +02:00
parent 5ebcc4feb6
commit f025ecd0bb

View File

@ -328,6 +328,7 @@ if [ "${1:-}" = "--help" ]; then
echo " --help Show this help and exit"
echo " --new Create new entry"
echo " --today Show today's appointments"
echo " --goto Interactively enter date to jump to"
echo " --day <day> Show appointments of specified day"
echo " --date <date> Show week of specified date"
exit
@ -337,6 +338,17 @@ if [ "${1:-}" = "--today" ]; then
exec $0 --day "today"
fi
if [ "${1:-}" = "--goto" ]; then
DISPLAY_DATE=""
while [ -z "$DISPLAY_DATE" ]; do
printf "Enter date you want to jump to, e.g., today + 1 month or 2024-1-14: " >/dev/tty
read -r tmp
if date -d "$tmp"; then
DISPLAY_DATE="$tmp"
fi
done
fi
if [ "${1:-}" = "--new" ]; then
collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | $FZF --delimiter='=' --with-nth=2 --accept-nth=1)
fpath=""
@ -541,7 +553,6 @@ selection=$(
--accept-nth=1,2 \
--no-info \
--ansi \
--no-clear \
--no-scrollbar \
--preview-window=up,7,border-bottom \
--preview="$0 --preview-week {}" \
@ -554,6 +565,7 @@ selection=$(
--bind="ctrl-alt-u:become($0 --date '$DISPLAY_DATE_PREV_MONTH')" \
--bind="ctrl-alt-d:become($0 --date '$DISPLAY_DATE_NEXT_MONTH')" \
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
--bind="ctrl-g:become($0 --goto)" \
--bind="ctrl-l:become($0)"
)