improved view, fixes
This commit is contained in:
20
fzf-vjour
20
fzf-vjour
@@ -27,6 +27,12 @@ SED_COLLECTIONLABELS_TO_NAMES=$(
|
|||||||
COLLECTION_NAME_MAX_LEN=$(yq '[.collections[].name | length] | max' <"$CONFIGFILE")
|
COLLECTION_NAME_MAX_LEN=$(yq '[.collections[].name | length] | max' <"$CONFIGFILE")
|
||||||
LABLES=$(yq '.collections[].label' <"$CONFIGFILE")
|
LABLES=$(yq '.collections[].label' <"$CONFIGFILE")
|
||||||
SYNC_CMD=$(yq '.sync_cmd' <"$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() {
|
__vtodopriority() {
|
||||||
python3 -c '
|
python3 -c '
|
||||||
@@ -385,6 +391,8 @@ __filepath_to_searchline() {
|
|||||||
totallen=$((maxlen + ${#ROOT} + COLLECTION_NAME_MAX_LEN + 2))
|
totallen=$((maxlen + ${#ROOT} + COLLECTION_NAME_MAX_LEN + 2))
|
||||||
#filepathpad=$(printf "%-${totallen}s" "$filepath")
|
#filepathpad=$(printf "%-${totallen}s" "$filepath")
|
||||||
filepathpad=$(dirname "$filepath")/$(printf "%-${maxlen}s" "$(basename "$filepath")")
|
filepathpad=$(dirname "$filepath")/$(printf "%-${maxlen}s" "$(basename "$filepath")")
|
||||||
|
collection=$(dirname "$filepath" | sed "s|^$ROOT/*||")
|
||||||
|
filename=$(basename "$filepath")
|
||||||
|
|
||||||
# Color support
|
# Color support
|
||||||
GREEN=$(printf '\033[1;32m')
|
GREEN=$(printf '\033[1;32m')
|
||||||
@@ -394,7 +402,7 @@ __filepath_to_searchline() {
|
|||||||
OFF=$(printf '\033[m')
|
OFF=$(printf '\033[m')
|
||||||
|
|
||||||
# Parse file
|
# 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)
|
categories=$(grep '^CATEGORIES:' "$filepath" | cut -d ':' -f 2)
|
||||||
dtstamp=$(grep '^DTSTAMP:' "$filepath" | cut -d ':' -f 2)
|
dtstamp=$(grep '^DTSTAMP:' "$filepath" | cut -d ':' -f 2)
|
||||||
dtstart=$(grep '^DTSTART' "$filepath" | grep -oE '[0-9]{8}')
|
dtstart=$(grep '^DTSTART' "$filepath" | grep -oE '[0-9]{8}')
|
||||||
@@ -445,7 +453,8 @@ __filepath_to_searchline() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Print line
|
# 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() {
|
__lines() {
|
||||||
@@ -475,8 +484,9 @@ __lines() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__filepath_from_selection() {
|
__filepath_from_selection() {
|
||||||
selection=$(echo "$1" | cut -d " " -f 1,2 | eval "$SED_COLLECTIONLABELS_TO_NAMES" | sed "s|^|$ROOT/|")
|
filename=$(echo "$1" | rev | cut -d "/" -f 1 | rev)
|
||||||
echo "$selection"
|
dirname=$(echo "$1" | cut -d " " -f 1 | eval "$SED_COLLECTIONLABELS_TO_NAMES" | sed "s|^|$ROOT|")
|
||||||
|
echo "$dirname/$filename"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Program starts here
|
# Program starts here
|
||||||
@@ -521,7 +531,7 @@ if [ "${1:-}" = "--new" ]; then
|
|||||||
file=""
|
file=""
|
||||||
while [ -f "$file" ] || [ -z "$file" ]; do
|
while [ -f "$file" ] || [ -z "$file" ]; do
|
||||||
uuid=$(uuidgen)
|
uuid=$(uuidgen)
|
||||||
file=$(__filepath_from_selection "$collection $uuid.ics")
|
file=$(__filepath_from_selection "$collection /$uuid.ics")
|
||||||
done
|
done
|
||||||
tmpmd=$(mktemp --suffix='.md')
|
tmpmd=$(mktemp --suffix='.md')
|
||||||
tmpsha="$tmpmd.sha"
|
tmpsha="$tmpmd.sha"
|
||||||
|
|||||||
Reference in New Issue
Block a user