Skip to content

Instantly share code, notes, and snippets.

@bonkey
Last active October 23, 2017 11:43
Show Gist options
  • Save bonkey/1124c7268f0890670c0999d9f4319f93 to your computer and use it in GitHub Desktop.
Save bonkey/1124c7268f0890670c0999d9f4319f93 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
# Usage: drop sys-update.sh somewhere and call it in your .zshrc or .bash_profile with "-c" argument to
# see a reminder after $check_time without running "sys-update.sh -a":
# ~/.zshrc:
# [... at the end...]
# ~/.sys-update.sh -c
local check_file=.sys-check-ts
local check_time="+5d"
zparseopts -- c=check p=up_python g=up_gems b=up_brew a=opt_a
if [ -n "$opt_a" ]; then
up_gems=1
up_brew=1
up_vim=1
touch $HOME/$check_file
fi
upgrade_python() {
echo "Upgrading pythons eggs"
pipdate
# pip list --outdated --format=freeze | cut -d= -f 1 | xargs -n1 pip install -U
}
upgrade_gems() {
echo "Upgrading gems"
rm -f "$HOME/.zcompdump*"
gem update && gem cleanup
}
upgrade_brew() {
echo "Upgrading brew"
brew update && brew upgrade && brew cleanup
brew cask cleanup
}
upgrade_vim() {
echo "Upgrading vim"
cd ~/.vim/bundle && ./update.sh
}
check() {
test -n "`find $HOME -maxdepth 1 -name $check_file -mtime $check_time`" && echo "System not updated since $check_time. Please run sys-update.sh"
exit 0
}
test -n "$check" && check
test -n "$up_brew" && upgrade_brew
test -n "$up_gems" && upgrade_gems
test -n "$up_python" && upgrade_python
test -n "$up_vim" && upgrade_vim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment