move update code into function

This commit is contained in:
Nicole O'Connor 2020-11-17 15:44:13 -08:00
parent a1ef62f661
commit 78f2496c20
1 changed files with 24 additions and 20 deletions

View File

@ -1,21 +1,25 @@
if type git &> /dev/null && (( _zeesh_fresh_install != 1 )); then
ticker_message "zeesh: pulling from git" # TODO: less frequently, and background
start_dir="$(pwd)"
cd ~/.local/share/zeesh
git pull &> ~/.local/share/zeesh/pull.log
cd "${start_dir}"
_zshrc_updates_pending=0
if type md5sum &> /dev/null; then
cmp -s ~/.zshrc ~/.local/share/zeesh/zshrc-stub
if [[ $? -eq 1 ]]; then
cp ~/.local/share/zeesh/zshrc-stub ~/.zshrc
_zshrc_updates_pending=1
fi
fi
function zeesh_update () {
if type git &> /dev/null && (( _zeesh_fresh_install != 1 )); then
ticker_message "zeesh: pulling from git" # TODO: less frequently, and background
start_dir="$(pwd)"
[[ _zshrc_updates_pending -eq 1 ]] && ticker_message "zeesh: stub updates pending"
fi
cd ~/.local/share/zeesh
git pull &> ~/.local/share/zeesh/pull.log
cd "${start_dir}"
_zshrc_updates_pending=0
if type md5sum &> /dev/null; then
cmp -s ~/.zshrc ~/.local/share/zeesh/zshrc-stub
if [[ $? -eq 1 ]]; then
cp ~/.local/share/zeesh/zshrc-stub ~/.zshrc
_zshrc_updates_pending=1
fi
fi
[[ _zshrc_updates_pending -eq 1 ]] && ticker_message "zeesh: stub updates pending"
fi
}
zeesh_update