diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-08-26 06:35:32 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-08-26 06:35:32 +0200 |
commit | 9c9abeec69b08a5d3b9578ad91300f3a4fbce7b6 (patch) | |
tree | 95830975107f0ebbaff274590feaf426b1fe9483 /etc | |
parent | d7038d520083d6eee1a51a3bb7f73e10f86f5710 (diff) |
zshrc: add self-update function for hosts without ct
Diffstat (limited to 'etc')
-rw-r--r-- | etc/.zshrc | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 . } |