minor improvements
This commit is contained in:
18
src/main.sh
18
src/main.sh
@@ -145,14 +145,7 @@ if [ "${1:-}" = "--delete" ]; then
|
|||||||
fi
|
fi
|
||||||
# Generate new entry
|
# Generate new entry
|
||||||
if [ "${1:-}" = "--new" ]; then
|
if [ "${1:-}" = "--new" ]; then
|
||||||
label=$(printf "%s" "$COLLECTION_LABELS" |
|
collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | fzf --delimiter='=' --with-nth=2 --accept-nth=1)
|
||||||
awk 'BEGIN { FS="="; RS=";"; } {print $2}' |
|
|
||||||
$FZF \
|
|
||||||
--margin 20% \
|
|
||||||
--prompt="Select collection> ")
|
|
||||||
|
|
||||||
collection=$(printf "%s" "$COLLECTION_LABELS" |
|
|
||||||
awk -v label="$label" 'BEGIN { FS="="; RS=";"; } $2 == label {print $1}')
|
|
||||||
file=""
|
file=""
|
||||||
while [ -f "$file" ] || [ -z "$file" ]; do
|
while [ -f "$file" ] || [ -z "$file" ]; do
|
||||||
uuid=$(uuidgen)
|
uuid=$(uuidgen)
|
||||||
@@ -230,10 +223,8 @@ fi
|
|||||||
if [ "${1:-}" = "--no-journal" ]; then
|
if [ "${1:-}" = "--no-journal" ]; then
|
||||||
query="!📘"
|
query="!📘"
|
||||||
fi
|
fi
|
||||||
if [ -z "$query" ]; then
|
query=${query:-!✅}
|
||||||
query="!✅"
|
query=$(echo "$query" | xargs)
|
||||||
fi
|
|
||||||
query=$(echo "$query" | sed 's/ *$//g')
|
|
||||||
|
|
||||||
selection=$(
|
selection=$(
|
||||||
__lines | $FZF --ansi \
|
__lines | $FZF --ansi \
|
||||||
@@ -252,7 +243,7 @@ selection=$(
|
|||||||
--bind="alt-1:change-query(📘)" \
|
--bind="alt-1:change-query(📘)" \
|
||||||
--bind="alt-2:change-query(🗒️)" \
|
--bind="alt-2:change-query(🗒️)" \
|
||||||
--bind="alt-3:change-query(✅ | 🔲)" \
|
--bind="alt-3:change-query(✅ | 🔲)" \
|
||||||
--bind="ctrl-s:execute($SYNC_CMD ; echo 'Press <enter> to continue.'; read -r tmp)"
|
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)"
|
||||||
)
|
)
|
||||||
if [ -z "$selection" ]; then
|
if [ -z "$selection" ]; then
|
||||||
return 0
|
return 0
|
||||||
@@ -275,7 +266,6 @@ $EDITOR "$filetmp" >/dev/tty
|
|||||||
|
|
||||||
# Update only if changes are detected
|
# Update only if changes are detected
|
||||||
if [ "$checksum" != "$(cksum "$filetmp")" ]; then
|
if [ "$checksum" != "$(cksum "$filetmp")" ]; then
|
||||||
echo "Uh... chages detected!" >/dev/tty
|
|
||||||
file_new="$filetmp.ics"
|
file_new="$filetmp.ics"
|
||||||
awk "$AWK_UPDATE" "$filetmp" "$file" >"$file_new"
|
awk "$AWK_UPDATE" "$filetmp" "$file" >"$file_new"
|
||||||
mv "$file_new" "$file"
|
mv "$file_new" "$file"
|
||||||
|
|||||||
Reference in New Issue
Block a user