diff options
| author | Marc Vertes <mvertes@free.fr> | 2021-06-13 14:49:53 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2021-06-13 14:49:53 +0200 |
| commit | 2621ec5405f52343cf253d02e307c5b160cf7f04 (patch) | |
| tree | 6321b8ea455258dbd9871c7fcc91205511c32beb | |
| parent | 445652e876c99ea24f7211f356c2a3d2c41d5d09 (diff) | |
update
| -rwxr-xr-x | bin/update_hosts | 8 | ||||
| -rwxr-xr-x | bin/vimki | 29 |
2 files changed, 33 insertions, 4 deletions
diff --git a/bin/update_hosts b/bin/update_hosts index e7321bf..8550ec3 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -13,11 +13,11 @@ echo "last local update: $(date -r /etc/hosts)" cd /etc cp -p hosts hosts.old -hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old) +hosts=$(awk '/^# Custom host/, /^# End of custom host/' hosts.old) curl -s 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts' | awk ' - BEGIN { hosts = ARGV[1]; ARGV[1] = "" } - /^# Custom host / { print hosts; next } - /^# End of custom host / { next } + BEGIN { hosts = ARGV[1]; ARGV[1] = "" } + /^# Custom host/ { print hosts; next } + /^# End of custom host/ { next } { print } ' "$hosts" > hosts.new diff --git a/bin/vimki b/bin/vimki new file mode 100755 index 0000000..50ab6ea --- /dev/null +++ b/bin/vimki @@ -0,0 +1,29 @@ +#!/bin/sh + +# Batch operations on vimki + +# 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" +} + +linkfile() { + echo "$1" + #echo "$1" | tr '[:upper:] àçéèêëîïôèùûü' '[:lower:]_aceeeeiiouuu' +} + +rename() { + for f in *; do + rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" + done + oldf="$(linkfile "$1")" + [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2")" +} + +cd ~/Wiki +"$@" |
