use whitespace free paths only
This commit is contained in:
@@ -130,6 +130,21 @@ ENDFILE {
|
|||||||
if (!type) {
|
if (!type) {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
# Construct path, and check for validity
|
||||||
|
depth = split(FILENAME, path, "/");
|
||||||
|
fpath = path[depth-1] "/" path[depth]
|
||||||
|
if (index(fpath, " "))
|
||||||
|
{
|
||||||
|
print 10,
|
||||||
|
"-",
|
||||||
|
"-",
|
||||||
|
RED "ERROR: file '" fpath "' contains whitespaces!" OFF
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
# Collection name
|
||||||
|
collection = path[depth-1]
|
||||||
|
collection = collection in collection2label ? collection2label[collection] : collection;
|
||||||
|
|
||||||
# Process content lines
|
# Process content lines
|
||||||
storetext_line(content_line, c, "CATEGORIES" );
|
storetext_line(content_line, c, "CATEGORIES" );
|
||||||
storetext_line(content_line, c, "DESCRIPTION" );
|
storetext_line(content_line, c, "DESCRIPTION" );
|
||||||
@@ -160,11 +175,6 @@ ENDFILE {
|
|||||||
# format
|
# format
|
||||||
mod = c["LAST-MODIFIED"] ? c["LAST-MODIFIED"] : c["DTSTAMP"];
|
mod = c["LAST-MODIFIED"] ? c["LAST-MODIFIED"] : c["DTSTAMP"];
|
||||||
|
|
||||||
# Collection name
|
|
||||||
depth = split(FILENAME, path, "/");
|
|
||||||
collection = depth > 1 ? path[depth-1] : "";
|
|
||||||
collection = collection in collection2label ? collection2label[collection] : collection;
|
|
||||||
|
|
||||||
# Date field. For VTODO entries, we show the due date, for journal entries,
|
# Date field. For VTODO entries, we show the due date, for journal entries,
|
||||||
# the associated date.
|
# the associated date.
|
||||||
datecolor = CYAN;
|
datecolor = CYAN;
|
||||||
@@ -206,10 +216,10 @@ ENDFILE {
|
|||||||
|
|
||||||
print prio,
|
print prio,
|
||||||
mod,
|
mod,
|
||||||
|
fpath,
|
||||||
collection,
|
collection,
|
||||||
datecolor d OFF,
|
datecolor d OFF,
|
||||||
flag,
|
flag,
|
||||||
priotext summarycolor summary OFF,
|
priotext summarycolor summary OFF,
|
||||||
WHITE categories OFF,
|
WHITE categories OFF;
|
||||||
" " FAINT FILENAME OFF;
|
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/main.sh
26
src/main.sh
@@ -105,12 +105,7 @@ __lines() {
|
|||||||
-v flag_journal="📘" \
|
-v flag_journal="📘" \
|
||||||
-v flag_note="🗒️" \
|
-v flag_note="🗒️" \
|
||||||
"$AWK_LIST" |
|
"$AWK_LIST" |
|
||||||
sort -g -r |
|
sort -g -r
|
||||||
cut -d ' ' -f 3-
|
|
||||||
}
|
|
||||||
|
|
||||||
__filepath_from_selection() {
|
|
||||||
echo "$1" | grep -o ' \{50\}.*$' | xargs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Program starts here
|
# Program starts here
|
||||||
@@ -142,14 +137,16 @@ fi
|
|||||||
# Command line arguments to be self-contained
|
# Command line arguments to be self-contained
|
||||||
# Generate preview of file from selection
|
# Generate preview of file from selection
|
||||||
if [ "${1:-}" = "--preview" ]; then
|
if [ "${1:-}" = "--preview" ]; then
|
||||||
file=$(__filepath_from_selection "$2")
|
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||||
|
file="$ROOT/$name"
|
||||||
awk -v field="DESCRIPTION" "$AWK_GET" "$file" |
|
awk -v field="DESCRIPTION" "$AWK_GET" "$file" |
|
||||||
$CAT
|
$CAT
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
# Delete file from selection
|
# Delete file from selection
|
||||||
if [ "${1:-}" = "--delete" ]; then
|
if [ "${1:-}" = "--delete" ]; then
|
||||||
file=$(__filepath_from_selection "$2")
|
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||||
|
file="$ROOT/$name"
|
||||||
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$file")
|
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$file")
|
||||||
while true; do
|
while true; do
|
||||||
printf "Do you want to delete the entry with the title \"%s\"? (yes/no): " "$summary" >/dev/tty
|
printf "Do you want to delete the entry with the title \"%s\"? (yes/no): " "$summary" >/dev/tty
|
||||||
@@ -199,21 +196,24 @@ if [ "${1:-}" = "--new" ]; then
|
|||||||
fi
|
fi
|
||||||
# Toggle completed flag
|
# Toggle completed flag
|
||||||
if [ "${1:-}" = "--toggle-completed" ]; then
|
if [ "${1:-}" = "--toggle-completed" ]; then
|
||||||
file=$(__filepath_from_selection "$2")
|
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||||
|
file="$ROOT/$name"
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
awk "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
awk "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
||||||
mv "$tmpfile" "$file"
|
mv "$tmpfile" "$file"
|
||||||
fi
|
fi
|
||||||
# Increase priority
|
# Increase priority
|
||||||
if [ "${1:-}" = "--increase-priority" ]; then
|
if [ "${1:-}" = "--increase-priority" ]; then
|
||||||
file=$(__filepath_from_selection "$2")
|
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||||
|
file="$ROOT/$name"
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
awk -v delta="1" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
awk -v delta="1" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
||||||
mv "$tmpfile" "$file"
|
mv "$tmpfile" "$file"
|
||||||
fi
|
fi
|
||||||
# Decrease priority
|
# Decrease priority
|
||||||
if [ "${1:-}" = "--decrease-priority" ]; then
|
if [ "${1:-}" = "--decrease-priority" ]; then
|
||||||
file=$(__filepath_from_selection "$2")
|
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||||
|
file="$ROOT/$name"
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
awk -v delta="-1" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
awk -v delta="-1" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
||||||
mv "$tmpfile" "$file"
|
mv "$tmpfile" "$file"
|
||||||
@@ -257,6 +257,8 @@ selection=$(
|
|||||||
--no-sort \
|
--no-sort \
|
||||||
--no-hscroll \
|
--no-hscroll \
|
||||||
--ellipsis='' \
|
--ellipsis='' \
|
||||||
|
--with-nth=4.. \
|
||||||
|
--accept-nth=3 \
|
||||||
--preview="$0 --preview {}" \
|
--preview="$0 --preview {}" \
|
||||||
--bind="ctrl-r:reload-sync($0 --reload)" \
|
--bind="ctrl-r:reload-sync($0 --reload)" \
|
||||||
--bind="ctrl-alt-d:become($0 --delete {})" \
|
--bind="ctrl-alt-d:become($0 --delete {})" \
|
||||||
@@ -274,7 +276,7 @@ if [ -z "$selection" ]; then
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
file=$(__filepath_from_selection "$selection")
|
file="$ROOT/$selection"
|
||||||
|
|
||||||
if [ ! -f "$file" ]; then
|
if [ ! -f "$file" ]; then
|
||||||
echo "ERROR: File '$file' does not exist!" >/dev/tty
|
echo "ERROR: File '$file' does not exist!" >/dev/tty
|
||||||
|
|||||||
Reference in New Issue
Block a user