diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-20 20:10:40 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-20 20:10:40 +0100 |
commit | e42f18fd5539182b6638987eeaffb6cb82f9e738 (patch) | |
tree | 80d4252fc4602042b6880a0ea8e3d5211598ec32 /pkgs/by-name/ne/neorg/functions/inputs.sh | |
parent | fix(pkgs/neorg/inputs): Add git support and fix further bugs (diff) | |
download | nixos-config-e42f18fd5539182b6638987eeaffb6cb82f9e738.tar.gz nixos-config-e42f18fd5539182b6638987eeaffb6cb82f9e738.zip |
fix(pkgs/neorg/inputs): Improve git integration and bound review prime
Diffstat (limited to '')
-rw-r--r-- | pkgs/by-name/ne/neorg/functions/inputs.sh | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/pkgs/by-name/ne/neorg/functions/inputs.sh b/pkgs/by-name/ne/neorg/functions/inputs.sh index 52efcc47..d47b129a 100644 --- a/pkgs/by-name/ne/neorg/functions/inputs.sh +++ b/pkgs/by-name/ne/neorg/functions/inputs.sh @@ -1,5 +1,14 @@ #!/usr/bin/env dash +_git_commit() { + message="$1" + + cd "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" || die "BUG. This should exist." + [ -d .git ] || git init + git add . + git commit --message "$message" --no-gpg-sign +} + inputs0add() { url_file="$1" @@ -14,11 +23,7 @@ inputs0add() { } >>"%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 + _git_commit "Add entries from '$url_file' ($(clean "$url_file" | wc -l))" } inputs0review() { @@ -33,12 +38,16 @@ inputs0review() { # Give it some time to start up. sleep 2 - while read -r url; do - msg "Adding url '$url'" + if [ "$(wc -l <"%NEORG_INPUTS_STORAGE_FILE")" -gt 100 ]; then + echo "Your would want to review more than 100 inputs. Limiting it to the first 100 entries." + fi + + head --lines=100 "%NEORG_INPUTS_STORAGE_FILE" | while read -r url; do + echo "-> '$url'" firefox -P "$base_profile" "$url" echo "$url" >>"$done_urls" - done <"%NEORG_INPUTS_STORAGE_FILE" + done # Wait for the Firefox process from above to finish. wait @@ -48,6 +57,6 @@ inputs0review() { 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 + + _git_commit "Dump entries into firefox profile '$base_profile'" } |