export variables and use them in subprocesses
This commit is contained in:
125
src/main.sh
125
src/main.sh
@@ -5,77 +5,96 @@ set -eu
|
||||
err() {
|
||||
echo "❌ $1" >/dev/tty
|
||||
}
|
||||
# Read configuration
|
||||
CONFIGFILE="$HOME/.config/fzf-vjour/config"
|
||||
if [ ! -f "$CONFIGFILE" ]; then
|
||||
err "Configuration '$CONFIGFILE' not found."
|
||||
exit 1
|
||||
fi
|
||||
# shellcheck source=/dev/null
|
||||
. "$CONFIGFILE"
|
||||
if [ -z "${ROOT:-}" ] || [ -z "${SYNC_CMD:-}" ] || [ -z "${COLLECTION_LABELS:-}" ]; then
|
||||
err "Configuration is incomplete."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Tools
|
||||
if command -v "fzf" >/dev/null; then
|
||||
FZF="fzf"
|
||||
else
|
||||
err "Did not find the command-line fuzzy finder fzf."
|
||||
exit 1
|
||||
fi
|
||||
if command -v "uuidgen" >/dev/null; then
|
||||
UUIDGEN="uuidgen"
|
||||
else
|
||||
err "Did not find the uuidgen command."
|
||||
exit 1
|
||||
fi
|
||||
if command -v "bat" >/dev/null; then
|
||||
CAT="bat"
|
||||
elif command -v "batcat" >/dev/null; then
|
||||
CAT="batcat"
|
||||
fi
|
||||
CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
|
||||
CAT=${CAT:-cat}
|
||||
if [ -z "${FZF_VJOUR_USE_EXPORTED:-}" ]; then
|
||||
# Read configuration
|
||||
CONFIGFILE="$HOME/.config/fzf-vjour/config"
|
||||
if [ ! -f "$CONFIGFILE" ]; then
|
||||
err "Configuration '$CONFIGFILE' not found."
|
||||
exit 1
|
||||
fi
|
||||
# shellcheck source=/dev/null
|
||||
. "$CONFIGFILE"
|
||||
if [ -z "${ROOT:-}" ] || [ -z "${SYNC_CMD:-}" ] || [ -z "${COLLECTION_LABELS:-}" ]; then
|
||||
err "Configuration is incomplete."
|
||||
exit 1
|
||||
fi
|
||||
export ROOT
|
||||
export SYNC_CMD
|
||||
export COLLECTION_LABELS
|
||||
|
||||
### AWK SCRIPTS
|
||||
AWK_ALTERTODO=$(
|
||||
cat <<'EOF'
|
||||
# Tools
|
||||
if command -v "fzf" >/dev/null; then
|
||||
FZF="fzf"
|
||||
else
|
||||
err "Did not find the command-line fuzzy finder fzf."
|
||||
exit 1
|
||||
fi
|
||||
export FZF
|
||||
|
||||
if command -v "uuidgen" >/dev/null; then
|
||||
UUIDGEN="uuidgen"
|
||||
else
|
||||
err "Did not find the uuidgen command."
|
||||
exit 1
|
||||
fi
|
||||
export UUIDGEN
|
||||
|
||||
if command -v "bat" >/dev/null; then
|
||||
CAT="bat"
|
||||
elif command -v "batcat" >/dev/null; then
|
||||
CAT="batcat"
|
||||
fi
|
||||
CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
|
||||
CAT=${CAT:-cat}
|
||||
export CAT
|
||||
|
||||
### AWK SCRIPTS
|
||||
AWK_ALTERTODO=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/altertodo.awk
|
||||
EOF
|
||||
)
|
||||
)
|
||||
export AWK_ALTERTODO
|
||||
|
||||
AWK_EXPORT=$(
|
||||
cat <<'EOF'
|
||||
AWK_EXPORT=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/export.awk
|
||||
EOF
|
||||
)
|
||||
)
|
||||
export AWK_EXPORT
|
||||
|
||||
AWK_GET=$(
|
||||
cat <<'EOF'
|
||||
AWK_GET=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/get.awk
|
||||
EOF
|
||||
)
|
||||
)
|
||||
export AWK_GET
|
||||
|
||||
AWK_LIST=$(
|
||||
cat <<'EOF'
|
||||
AWK_LIST=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/list.awk
|
||||
EOF
|
||||
)
|
||||
)
|
||||
export AWK_LIST
|
||||
|
||||
AWK_NEW=$(
|
||||
cat <<'EOF'
|
||||
AWK_NEW=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/new.awk
|
||||
EOF
|
||||
)
|
||||
)
|
||||
export AWK_NEW
|
||||
|
||||
AWK_UPDATE=$(
|
||||
cat <<'EOF'
|
||||
AWK_UPDATE=$(
|
||||
cat <<'EOF'
|
||||
@@include src/awk/update.awk
|
||||
EOF
|
||||
)
|
||||
### END OF AWK SCRIPTS
|
||||
)
|
||||
export AWK_UPDATE
|
||||
### END OF AWK SCRIPTS
|
||||
FZF_VJOUR_USE_EXPORTED="yes"
|
||||
export FZF_VJOUR_USE_EXPORTED
|
||||
fi
|
||||
|
||||
__lines() {
|
||||
find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \
|
||||
@@ -133,7 +152,7 @@ if [ "${1:-}" = "--delete" ]; then
|
||||
file=$(__filepath_from_selection "$2")
|
||||
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
|
||||
printf "Do you want to delete the entry with the title \"%s\"? (yes/no): " "$summary" >/dev/tty
|
||||
read -r yn
|
||||
case $yn in
|
||||
"yes")
|
||||
|
||||
Reference in New Issue
Block a user