feat: keybindings for collections

This commit is contained in:
2025-07-04 13:57:05 +02:00
parent f663c200d2
commit 5f05bc2e0f
4 changed files with 41 additions and 9 deletions

View File

@@ -90,9 +90,10 @@ In addition, there are the following keybindings:
| `ctrl-t` | Filter by category |
| `alt-v` | View bare iCalendar file |
| `alt-0` | Default view: Journal, notes, and _open_ tasks |
| `alt-1` | Display journal entries |
| `alt-2` | Display notes |
| `alt-3` | Display all tasks |
| `alt-j` | Display journal entries |
| `alt-n` | Display notes |
| `alt-t` | Display all tasks |
| `alt-[1-9]` | Display first, second, ... collection |
You may also invoke the script with `--help` to see further command-line options.

View File

@@ -89,12 +89,21 @@ while true; do
--bind="ctrl-x:reload($0 --reload --toggle-completed {4})" \
--bind="alt-up:reload($0 --reload --change-priority '+1' {4})" \
--bind="alt-down:reload($0 --reload --change-priority '-1' {4})" \
--bind="alt-0:change-query(!✅)" \
--bind="alt-1:change-query(📘)" \
--bind="alt-2:change-query(🗒️)" \
--bind="alt-3:change-query(✅ | 🔲)" \
--bind="alt-0:change-query(!$FLAG_COMPLETED )" \
--bind="alt-1:change-query(${COLLECTION1:-} )" \
--bind="alt-2:change-query(${COLLECTION2:-} )" \
--bind="alt-3:change-query(${COLLECTION3:-} )" \
--bind="alt-4:change-query(${COLLECTION4:-} )" \
--bind="alt-5:change-query(${COLLECTION5:-} )" \
--bind="alt-6:change-query(${COLLECTION6:-} )" \
--bind="alt-7:change-query(${COLLECTION7:-} )" \
--bind="alt-8:change-query(${COLLECTION8:-} )" \
--bind="alt-9:change-query(${COLLECTION9:-} )" \
--bind="alt-j:change-query($FLAG_JOURNAL )" \
--bind="alt-n:change-query($FLAG_NOTE )" \
--bind="alt-t:change-query($FLAG_COMPLETED | $FLAG_OPEN )" \
--bind='focus:transform:[ {3} = "VTODO" ] && echo "rebind(ctrl-x)+rebind(alt-up)+rebind(alt-down)" || echo "unbind(ctrl-x)+unbind(alt-up)+unbind(alt-down)"' \
--bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && ${GIT:-echo} add -A; ${GIT:-echo} commit -am 'Synchronized'; printf 'Press <enter> to continue.'; read -r tmp)" ||
--bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && ${GIT:-echo} add -A && ${GIT:-echo} commit -am 'Synchronized'; printf 'Press <enter> to continue.'; read -r tmp)" ||
true
)

View File

@@ -13,6 +13,14 @@ SYNC_CMD="${SYNC_CMD:-}"
export ROOT
export SYNC_CMD
export COLLECTION_LABELS
for i in $(seq 9); do
label=$(printf "%s" "$COLLECTION_LABELS" | cut -d ';' -f "$i" | cut -d '=' -f 2)
if [ -z "$label" ]; then
export COLLECTION_COUNT=$((i - 1))
break
fi
export "COLLECTION$i=$label"
done
# Tools
if command -v "fzf" >/dev/null; then

View File

@@ -109,7 +109,21 @@ __delete() {
# Add file
__new() {
collection=$(printf "%s" "$COLLECTION_LABELS" | tr ';' '\n' | $FZF --delimiter='=' --with-nth=2 --accept-nth=1)
collection=$(printf "%s" "$COLLECTION_LABELS" |
tr ';' '\n' |
$FZF \
--prompt="Choose collection> " \
--no-sort \
--tac \
--margin="30%,30%" \
--delimiter='=' \
--border=bold \
--border-label="Collections" \
--with-nth=2 \
--accept-nth=1 || true)
if [ -z "$collection" ]; then
return
fi
file=""
while [ -f "$file" ] || [ -z "$file" ]; do
uuid=$($UUIDGEN)