bin: improve utils for roam

This commit is contained in:
xeruf 2021-11-11 17:31:53 +01:00
parent 9d36a94b1a
commit 61c2591277
2 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,8 @@
#!/bin/sh
# Stage moved files fitting the already staged ones
git diff --name-only --cached >/tmp/staged
git add $(git rev-parse --show-toplevel)
git status -s | tail +2 | grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' | xargs git restore --staged
root=$(git rev-parse --show-toplevel)
git add "$root"
git status --porcelain --find-renames=.3 |
grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' |
xargs git -C "$root" restore --staged

View File

@ -1,4 +1,8 @@
#!/bin/sh -e
# Move roam files into subfolders
cd $DATA/2-standards/notes
find . -mindepth 1 -type d -printf '%f\n' | while read dir; do grep -l --directories=skip "#+filetags: :$dir" * | xargs --verbose --no-run-if-empty mv -t "$dir"; done
find . -mindepth 1 -type d -printf '%f\n' |
while read dir; do
grep -l --directories=skip "#+filetags: :$dir" * |
xargs --verbose --no-run-if-empty mv -t "$dir"
done