diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/vimki | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -5,8 +5,16 @@ # rename changes the link name and propagates the change in the wiki rename1() { gawk -v old="$1" -v new="$2" -v IGNORECASE=1 ' + { + gsub("[[]" old "[]]", "[" new "]") + print + } + ' "$3" +} + +link2rx() { + gawk -v rx="$1" -v IGNORECASE=1 ' BEGIN { - rx = old gsub(/_/, "\\W+", rx) gsub(/a/, "[aåäáàâã]", rx) gsub(/c/, "[cç]", rx) @@ -16,12 +24,8 @@ rename1() { gsub(/u/, "[uùûüú]", rx) gsub(/y/, "[yÿ]", rx) gsub(/n/, "[nñ]", rx) - } - { - gsub("[[]" rx "[]]", "[" new "]") - print - } - ' "$3" + print rx + }' } #shellcheck disable=SC2020 @@ -34,9 +38,10 @@ linkfile() { } rename() { + rx=$(link2rx "$1") for f in *.md; do [ "$(head -c 8 "$f")" = VimCrypt ] && continue - rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" + rename1 "$rx" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" done oldf="$(linkfile "$1").md" [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2").md" |
