From 61c2591277e91ecb5072ff358aa74e9302fc82a9 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 11 Nov 2021 17:31:53 +0100 Subject: [PATCH] bin: improve utils for roam --- .local/bin/scripts/git-moves | 7 +++++-- .local/bin/scripts/roam | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.local/bin/scripts/git-moves b/.local/bin/scripts/git-moves index 101a383..77130c1 100755 --- a/.local/bin/scripts/git-moves +++ b/.local/bin/scripts/git-moves @@ -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 diff --git a/.local/bin/scripts/roam b/.local/bin/scripts/roam index cdd7677..bd8b4dd 100755 --- a/.local/bin/scripts/roam +++ b/.local/bin/scripts/roam @@ -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