use whitespace free paths only
This commit is contained in:
26
src/main.sh
26
src/main.sh
@@ -105,12 +105,7 @@ __lines() {
|
||||
-v flag_journal="📘" \
|
||||
-v flag_note="🗒️" \
|
||||
"$AWK_LIST" |
|
||||
sort -g -r |
|
||||
cut -d ' ' -f 3-
|
||||
}
|
||||
|
||||
__filepath_from_selection() {
|
||||
echo "$1" | grep -o ' \{50\}.*$' | xargs
|
||||
sort -g -r
|
||||
}
|
||||
|
||||
# Program starts here
|
||||
@@ -142,14 +137,16 @@ fi
|
||||
# Command line arguments to be self-contained
|
||||
# Generate preview of file from selection
|
||||
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" |
|
||||
$CAT
|
||||
exit
|
||||
fi
|
||||
# Delete file from selection
|
||||
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")
|
||||
while true; do
|
||||
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
|
||||
# Toggle completed flag
|
||||
if [ "${1:-}" = "--toggle-completed" ]; then
|
||||
file=$(__filepath_from_selection "$2")
|
||||
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||
file="$ROOT/$name"
|
||||
tmpfile=$(mktemp)
|
||||
awk "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
||||
mv "$tmpfile" "$file"
|
||||
fi
|
||||
# Increase priority
|
||||
if [ "${1:-}" = "--increase-priority" ]; then
|
||||
file=$(__filepath_from_selection "$2")
|
||||
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||
file="$ROOT/$name"
|
||||
tmpfile=$(mktemp)
|
||||
awk -v delta="1" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
||||
mv "$tmpfile" "$file"
|
||||
fi
|
||||
# Decrease priority
|
||||
if [ "${1:-}" = "--decrease-priority" ]; then
|
||||
file=$(__filepath_from_selection "$2")
|
||||
name=$(echo "$2" | cut -d ' ' -f 3)
|
||||
file="$ROOT/$name"
|
||||
tmpfile=$(mktemp)
|
||||
awk -v delta="-1" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
||||
mv "$tmpfile" "$file"
|
||||
@@ -257,6 +257,8 @@ selection=$(
|
||||
--no-sort \
|
||||
--no-hscroll \
|
||||
--ellipsis='' \
|
||||
--with-nth=4.. \
|
||||
--accept-nth=3 \
|
||||
--preview="$0 --preview {}" \
|
||||
--bind="ctrl-r:reload-sync($0 --reload)" \
|
||||
--bind="ctrl-alt-d:become($0 --delete {})" \
|
||||
@@ -274,7 +276,7 @@ if [ -z "$selection" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
file=$(__filepath_from_selection "$selection")
|
||||
file="$ROOT/$selection"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "ERROR: File '$file' does not exist!" >/dev/tty
|
||||
|
||||
Reference in New Issue
Block a user