#!/usr/bin/env dash inputs0add() { url_file="$1" mkdir --parents "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" { # Add another newline echo "" # echo "# $url_file " clean "$url_file" } >>"%NEORG_INPUTS_STORAGE_FILE" && msg2 "Successfully added file '$url_file' with $(clean "$url_file" | wc -l) entries to the url list" cd "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" || die "BUG. This should exist." [ -d .git ] || git init git add . git commit --message "Add entries from '$url_file' ($(clean "$url_file" | wc -l))" --no-gpg-sign } inputs0review() { base_profile="$1" [ -f "%NEORG_INPUTS_STORAGE_FILE" ] || die "'%NEORG_INPUTS_STORAGE_FILE' is not a file. Have you added something with 'inputs_add' yet?" done_urls="$(mktmp)" # We assume that the project is not yet open. firefox -P "$base_profile" & # Give it some time to start up. sleep 2 while read -r url; do msg "Adding url '$url'" firefox -P "$base_profile" "$url" echo "$url" >>"$done_urls" done <"%NEORG_INPUTS_STORAGE_FILE" # Wait for the Firefox process from above to finish. wait tmp="$(mktmp)" # source: https://stackoverflow.com/a/24324455 awk 'NR==FNR {a[$0]=1; next} !a[$0]' "$done_urls" "%NEORG_INPUTS_STORAGE_FILE" >"$tmp" mv "$tmp" "%NEORG_INPUTS_STORAGE_FILE" git add . git commit --message "Dump entries into firefox profile '$base_profile'" --no-gpg-sign }