From 9c9abeec69b08a5d3b9578ad91300f3a4fbce7b6 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 26 Aug 2018 06:35:32 +0200 Subject: zshrc: add self-update function for hosts without ct --- etc/.zshrc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/etc/.zshrc b/etc/.zshrc index e61197f..7c5d1bc 100644 --- a/etc/.zshrc +++ b/etc/.zshrc @@ -219,6 +219,24 @@ function rwdo { sudo mount -o remount,ro / } +function update-zshrc { + local readonly_root=0 + if [[ -L ~/.zshrc ]]; then + echo "zshrc is managed via caretaker -- please run 'ct f'" + else + if findmnt --raw --noheadings --output options --target ${HOME} | grep -qE '(^|,)ro($|,)'; then + readonly_root=1 + fi + if (( readonly_root )); then + sudo mount -o remount,rw / + fi + wget -O ~/.zshrc.new https://git.finalrewind.org/zsh/plain/etc/.zshrc && mv ~/.zshrc.new ~/.zshrc + if (( readonly_root )); then + sudo mount -o remount,ro / + fi + fi +} + function world-readable { chmod -R a+rX . } -- cgit v1.2.3