From 903c870dbac7954777743f1533b1b5e9d31bbeb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Sat, 14 Jun 2025 22:30:21 +0200 Subject: [PATCH] improvement: rearranged keys --- README.md | 78 ++++++++++++++++++++++++++++++++++------------------- src/main.sh | 54 +++++++++++++++++++------------------ 2 files changed, 78 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 70bc155..475c0cd 100644 --- a/README.md +++ b/README.md @@ -79,39 +79,61 @@ Here is the complete list of configuration options: Usage ----- -Use the default `fzf` keys to navigate your calendar entries, e.g., `ctrl-j` -and `ctrl-k` for going down/up in the list. After starting `fzf-vcal`, you are presented with a view on the current week. +You can navigate that week using `j` and `h` for going down and up. Hit `` on any day, and you will see all entries for that date, including previews. In both, the week and day views, you can add entries by hitting `ctrl-n`. -Here is the list of available keybindings: -| Key | View | Action | -| --- | ---- | ------ | -| `enter` | week view | Switch to day view | -| `ctrl-n` | week view | Make a new entry | -| any letter | week view | Search in the list of all entries | -| `backspace` on empty query | week view | Undo search | -| `ctrl-u` | week view | Go back one week | -| `ctrl-d` | week view | Go forth one week | -| `ctrl-alt-u` | week view | Go back one month | -| `ctrl-alt-d` | week view | Go forth one month | -| `ctrl-s` | week view | Run the synchronization command | -| `ctrl-r` | week view | Go to current week | -| `ctrl-g` | week view | Goto date | -| `ctrl-t` | week view | Change timezone | -| `enter` | day view | Open selected calendar entry in your favorite `$EDITOR` | -| `ctrl-n` | day view | Make a new entry | -| `ctrl-l` | day view | Move to next day | -| `ctrl-h` | day view | Move to previous day | -| `esc`, `backspace` or `q` | day view | Go back to week view | -| `ctrl-s` | day view | Run the synchronization command | -| `ctrl-t` | day view | Change timezone | -| `ctrl-alt-d` | day view | Delete selected entry | -| `j` | day view | Scroll down in preview window | -| `k` | day view | Scroll up in preview window | -| `w` | day view | Toggle line wrap in preview window || +Here is the list of all available keybindings: + +### Week view + +| Key | Action | +| --- | ------ | +| `enter` | open day | +| `j` | down | +| `k` | up | +| `l` | go to next week | +| `h` | go to previous week | +| `ctrl-l` | go to next month | +| `ctrl-h` | go to previous month | +| `alt-l` | go to next year | +| `alt-h` | go to previous year | +| `ctrl-r` | reload and go to week that contains `today` | +| `ctrl-g` | interactively go to specified week | +| `ctrl-t` | set timezon | +| `ctrl-s` | synchronize | +| `ctrl-n` | add new entry | +| `\` | search all appointment s| + +### Day view + +| Key | Action | +| --- | ------ | +| `enter` | edit appointment | +| `j` | down | +| `k` | up | +| `l` | go to next day | +| `h` | go to previous day | +| `ctrl-l` | go to next week | +| `ctrl-h` | go to previous week | +| `alt-l` | go to next month | +| `alt-h` | go to previous month | +| `ctrl-r` | reload and go to `today` | +| `ctrl-g` | interactively go to specified day | +| `ctrl-t` | set timezon | +| `ctrl-s` | synchronize | +| `ctrl-n` | add new entry | +| `ctrl-alt-d` | delete entry | +| `w` | toggle line wrap in preview | +| `ctrl-d` | down in preview | +| `ctrl-u` | up in preview | +| `alt-v` | view raw iCalendar file | +| `esc` | return to week view, you can also do this with `q` or `backspace` | + + +### There is more You may also invoke the script with `--help` to see further command-line options. diff --git a/src/main.sh b/src/main.sh index d2353fa..e9e7d75 100755 --- a/src/main.sh +++ b/src/main.sh @@ -989,7 +989,7 @@ while true; do --with-nth='{6}' \ --accept-nth='1,2,3,4,5' \ --preview="$0 --preview-event {}" \ - --expect="ctrl-n,ctrl-alt-d,ctrl-t,ctrl-g,esc,backspace,q,v" \ + --expect="ctrl-n,ctrl-t,ctrl-g,ctrl-alt-d,esc,backspace,q,alt-v" \ --bind="load:pos(1)+transform( echo change-border-label:🗓️ \$(date -d {1} +\"%A %e %B %Y\") )+transform( @@ -998,15 +998,19 @@ while true; do echo {} | grep \|\| || echo show-preview )" \ --bind="start:hide-preview" \ - --bind="ctrl-r:reload:$0 --reload-day {1}" \ - --bind="ctrl-j:down+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \ - --bind="ctrl-k:up+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \ - --bind="ctrl-l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \ - --bind="ctrl-h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \ + --bind="j:down+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \ + --bind="k:up+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \ + --bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \ + --bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \ + --bind="ctrl-l:hide-preview+reload:$0 --reload-day {1} '+1 week'" \ + --bind="ctrl-h:hide-preview+reload:$0 --reload-day {1} '-1 week'" \ + --bind="alt-l:hide-preview+reload:$0 --reload-day {1} '+1 month'" \ + --bind="alt-h:hide-preview+reload:$0 --reload-day {1} '-1 month'" \ + --bind="ctrl-r:hide-preview+reload:$0 --reload-day today" \ --bind="ctrl-s:execute($SYNC_CMD ; printf 'Press to continue.'; read -r tmp)" \ - --bind="j:preview-down" \ - --bind="k:preview-down" \ - --bind="w:toggle-preview-wrap" + --bind="w:toggle-preview-wrap" \ + --bind="ctrl-d:preview-down" \ + --bind="ctrl-u:preview-up" ) key=$(echo "$selection" | head -1) line=$(echo "$selection" | tail -1) @@ -1033,7 +1037,7 @@ while true; do set -- "--set-tz" "--day" "$DISPLAY_DATE" elif [ "$key" = "esc" ] || [ "$key" = "backspace" ] || [ "$key" = "q" ]; then set -- "--week" "$DISPLAY_DATE" - elif [ "$key" = "v" ] && [ -f "$ROOT/$fpath" ]; then + elif [ "$key" = "alt-v" ] && [ -f "$ROOT/$fpath" ]; then $EDITOR "$ROOT/$fpath" elif [ -z "$key" ] && [ -n "$fpath" ]; then __edit "$start" "$end" "$fpath" @@ -1059,28 +1063,26 @@ while true; do --ansi \ --gap 1 \ --no-scrollbar \ + --no-input \ --info=right \ --info-command="printf \"$(date +"%R %Z")\"; [ -n \"\${TZ:-}\" ] && printf \" (\$TZ)\"" \ --preview-window=up,7,border-bottom \ --preview="$0 --preview-week {}" \ - --expect="ctrl-n,ctrl-g,ctrl-t" \ - --bind="ctrl-j:transform:([ {1} = \"+\" ] && [ \$FZF_POS -le 1 ]) && - echo unbind\(load\)+reload:$0 --reload-week {2} '+1 day'|| - echo down" \ - --bind="ctrl-k:transform:([ {1} = \"+\" ] && [ \$FZF_POS -ge 7 ]) && - echo unbind\(load\)+reload:$0 --reload-week {2} '-1 day'|| - echo up" \ - --bind="change:unbind(load)+reload($0 --reload-all)+hide-preview" \ --bind="load:pos($DISPLAY_POS)" \ - --bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \ - --bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \ - --bind="ctrl-u:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \ - --bind="ctrl-d:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \ - --bind="ctrl-alt-u:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \ - --bind="ctrl-alt-d:unbind(load)+reload:$0 --reload-week {2} '+1 month'" \ + --expect="ctrl-n,ctrl-g,ctrl-t" \ + --bind="j:down" \ + --bind="k:up" \ + --bind="l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \ + --bind="h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \ + --bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 month'" \ + --bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \ + --bind="alt-l:unbind(load)+reload:$0 --reload-week {2} '+1 year'" \ + --bind="alt-h:unbind(load)+reload:$0 --reload-week {2} '-1 year'" \ + --bind="ctrl-r:rebind(load)+reload($0 --reload-week today)+show-preview" \ --bind="ctrl-s:execute($SYNC_CMD ; printf 'Press to continue.'; read -r tmp)" \ - --bind="backward-eof:rebind(load)+reload($0 --reload-week today)+show-preview" \ - --bind="ctrl-r:rebind(load)+reload($0 --reload-week today)+show-preview" + --bind="/:show-input+unbind(j)+unbind(k)+unbind(l)+unbind(h)+unbind(ctrl-l)+unbind(ctrl-h)+unbind(alt-l)+unbind(alt-h)+unbind(load)+hide-preview+reload:$0 --reload-all" \ + --bind="backward-eof:hide-input+rebind(j)+rebind(k)+rebind(l)+rebind(h)+rebind(ctrl-l)+rebind(ctrl-h)+rebind(alt-l)+rebind(alt-h)+rebind(load)+show-preview+reload:$0 --reload-week today" \ + --bind="esc:clear-query+hide-input+rebind(j)+rebind(k)+rebind(l)+rebind(h)+rebind(ctrl-l)+rebind(ctrl-h)+rebind(alt-l)+rebind(alt-h)+rebind(load)+show-preview+reload:$0 --reload-week today" ) key=$(echo "$selection" | head -1)