diff --git a/src/main.sh b/src/main.sh index 993d55e..e27ac8d 100644 --- a/src/main.sh +++ b/src/main.sh @@ -91,24 +91,21 @@ while true; do --bind="alt-2:change-query(🗒️)" \ --bind="alt-3:change-query(✅ | 🔲)" \ --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:-} commit -am 'Synchronized'; printf 'Press to continue.'; read -r tmp)" + --bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && ${GIT:-} commit -am 'Synchronized'; printf 'Press to continue.'; read -r tmp)" || + true ) # Line 1: query # Line 2: key ("" for enter) # Line 3: relative file path + lines=$(echo "$selection" | wc -l) + if [ "$lines" -eq 1 ]; then + return 0 + fi query=$(echo "$selection" | head -n 1) key=$(echo "$selection" | head -n 2 | tail -n 1) fname=$(echo "$selection" | head -n 3 | tail -n 1) - if [ "$fname" = "$key" ]; then - fname="" - fi - file="$ROOT/$fname" - if [ ! -f "$file" ]; then - err "File '$file' does not exist!" - return 1 - fi case "$key" in "ctrl-n") @@ -123,7 +120,7 @@ while true; do "ctrl-a") __attachment_view "$file" ;; - *) + "") __edit "$file" ;; esac diff --git a/src/sh/config.sh b/src/sh/config.sh index 539d4f2..0ad7ed6 100644 --- a/src/sh/config.sh +++ b/src/sh/config.sh @@ -5,10 +5,11 @@ if [ ! -f "$CONFIGFILE" ]; then fi # shellcheck source=/dev/null . "$CONFIGFILE" -if [ -z "${ROOT:-}" ] || [ -z "${SYNC_CMD:-}" ] || [ -z "${COLLECTION_LABELS:-}" ]; then +if [ -z "${ROOT:-}" ] || [ -z "${COLLECTION_LABELS:-}" ]; then err "Configuration is incomplete." exit 1 fi +SYNC_CMD="${SYNC_CMD:-}" export ROOT export SYNC_CMD export COLLECTION_LABELS