summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-08-26 06:35:32 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-08-26 06:35:32 +0200
commit9c9abeec69b08a5d3b9578ad91300f3a4fbce7b6 (patch)
tree95830975107f0ebbaff274590feaf426b1fe9483 /etc
parentd7038d520083d6eee1a51a3bb7f73e10f86f5710 (diff)
zshrc: add self-update function for hosts without ct
Diffstat (limited to 'etc')
-rw-r--r--etc/.zshrc18
1 files changed, 18 insertions, 0 deletions
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 .
}