From 2df8fcf1bcc9d92b6d24f229fa757daa25977262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Fri, 23 May 2025 14:46:56 +0200 Subject: [PATCH] improved view, fixes --- fzf-vjour | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/fzf-vjour b/fzf-vjour index ca84027..6fb8d7d 100755 --- a/fzf-vjour +++ b/fzf-vjour @@ -27,6 +27,12 @@ SED_COLLECTIONLABELS_TO_NAMES=$( COLLECTION_NAME_MAX_LEN=$(yq '[.collections[].name | length] | max' <"$CONFIGFILE") LABLES=$(yq '.collections[].label' <"$CONFIGFILE") SYNC_CMD=$(yq '.sync_cmd' <"$CONFIGFILE") +LONGSPACE=" " + +if ! (yq '.collections[].label' | grep ' ') >/dev/null; then + echo "We currently do not support whitespaces in the labels" + exit 1 +fi __vtodopriority() { python3 -c ' @@ -385,6 +391,8 @@ __filepath_to_searchline() { totallen=$((maxlen + ${#ROOT} + COLLECTION_NAME_MAX_LEN + 2)) #filepathpad=$(printf "%-${totallen}s" "$filepath") filepathpad=$(dirname "$filepath")/$(printf "%-${maxlen}s" "$(basename "$filepath")") + collection=$(dirname "$filepath" | sed "s|^$ROOT/*||") + filename=$(basename "$filepath") # Color support GREEN=$(printf '\033[1;32m') @@ -394,7 +402,7 @@ __filepath_to_searchline() { OFF=$(printf '\033[m') # Parse file - summary=$(grep '^SUMMARY:' "$filepath" | cut -d ':' -f 2) + summary=$(grep '^SUMMARY:' "$filepath" | cut -d ':' -f 2 | sed 's/\\,/,/g') categories=$(grep '^CATEGORIES:' "$filepath" | cut -d ':' -f 2) dtstamp=$(grep '^DTSTAMP:' "$filepath" | cut -d ':' -f 2) dtstart=$(grep '^DTSTART' "$filepath" | grep -oE '[0-9]{8}') @@ -445,7 +453,8 @@ __filepath_to_searchline() { fi # Print line - echo "$priority $dtstamp $filepathpad $date_expr $emoji $prioritymsg$summary_color$summary$OFF $FAINT$categories$OFF" + echo "$priority $dtstamp $collection $date_expr $emoji $prioritymsg$summary_color$summary$OFF $FAINT$categories$OFF$LONGSPACE/$filename" + #echo "$priority $dtstamp $filepathpad $date_expr $emoji $prioritymsg$summary_color$summary$OFF $FAINT$categories$OFF" } __lines() { @@ -475,8 +484,9 @@ __lines() { } __filepath_from_selection() { - selection=$(echo "$1" | cut -d " " -f 1,2 | eval "$SED_COLLECTIONLABELS_TO_NAMES" | sed "s|^|$ROOT/|") - echo "$selection" + filename=$(echo "$1" | rev | cut -d "/" -f 1 | rev) + dirname=$(echo "$1" | cut -d " " -f 1 | eval "$SED_COLLECTIONLABELS_TO_NAMES" | sed "s|^|$ROOT|") + echo "$dirname/$filename" } # Program starts here @@ -521,7 +531,7 @@ if [ "${1:-}" = "--new" ]; then file="" while [ -f "$file" ] || [ -z "$file" ]; do uuid=$(uuidgen) - file=$(__filepath_from_selection "$collection $uuid.ics") + file=$(__filepath_from_selection "$collection /$uuid.ics") done tmpmd=$(mktemp --suffix='.md') tmpsha="$tmpmd.sha"