dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE

uu (2249B)


      1 #!/usr/bin/env zsh
      2 
      3 announce() {
      4 	echo -e "\n$(tput setaf 3)# $@$(tput sgr0)"
      5 }
      6 
      7 announce "Updating package manager lists and installed packages"
      8 if [ "$(uname)" = "Linux" ]; then
      9 	if type xbps-install >/dev/null; then
     10 		sudo xbps-install -Su
     11 		sudo xbps-remove -Oo
     12 	fi
     13 	if type pacman >/dev/null; then
     14 		sudo pacman -Syu
     15 		echo "Removing unneeded packages"
     16 		unused=$(pacman -Qdtq)
     17 		if [[ $(echo "$unused" | wc -l) -gt 1 ]]; then
     18 			echo "Unused packages:"
     19 			echo "$unused"
     20 			printf '%s ' 'Delete unused packages? [y/N]'
     21 			read REPLY
     22 			if [[ $REPLY =~ ^[Yy]$ ]]; then
     23 				sudo pacman -Rns $(echo $unused | tr '\n' ' ') --noconfirm
     24 			fi
     25 		fi
     26 
     27 		echo "Removing old packages"
     28 		sudo pacman -Sc --noconfirm
     29 	fi
     30 	if type yay >/dev/null; then
     31 		yay -Syu --color auto --noconfirm
     32 	fi
     33 	if type apt-get >/dev/null; then
     34 		sudo apt-get update && \
     35 			sudo apt-get -y upgrade && \
     36 			sudo apt-get -y dist-upgrade && \
     37 			sudo apt-get -y autoremove && \
     38 			sudo apt-get clean
     39 	fi
     40 
     41 elif type brew >/dev/null; then
     42 	echo "Fetching updates..."
     43 	brew analytics off
     44 	brew update && \
     45 		brew upgrade && \
     46 		brew cask upgrade && \
     47 		brew cleanup
     48 else
     49 	(>&2 echo "Platform not supported")
     50 	exit 1
     51 fi
     52 
     53 announce "Updating dotfiles"
     54 . ~/.commands.sh
     55 dotfiles pull
     56 dotfiles submodule foreach --recursive git pull origin master ; m_all_sl
     57 #announce "Finished building dotfiles"
     58 
     59 if type conda >/dev/null; then
     60 	announce "Upgrading conda packages"
     61 	conda update --all --yes
     62 fi
     63 
     64 if type julia >/dev/null; then
     65 	announce "Upgrading julia packages"
     66 	julia --color=yes -e 'import Pkg; Pkg.update()'
     67 fi
     68 
     69 if [ -d ~/code/zplug ]; then
     70 	announce "Upgrading zplug packages"
     71 	(zsh -c "source ~/.zshrc && zplug update")
     72 fi
     73 if [ -d ~/.zgen ]; then
     74 	announce "Upgrading zgen packages"
     75 	(zsh -c "source ~/.zshrc && zgen update && zgen save")
     76 fi
     77 if [ -d ~/code/fffs ]; then
     78 	announce "Upgrading fffs packages"
     79 	[ ! -h ~/.local/bin/fffs ] && ln -s ~/code/fffs/fffs ~/.local/bin/fffs
     80 	fffs zsh update
     81 fi
     82 
     83 if [ -d ~/.vim/vim-plugs ] && [ "$EDITOR" = "vim" ]; then
     84 	announce "Upgrading $EDITOR packages"
     85 	case "$EDITOR" in
     86 		*vim*)
     87 			$EDITOR +PlugUpgrade +PlugUpdate +qall;;
     88 	esac
     89 fi
     90 
     91 if [ "$1" = 'all' ]; then
     92 	ssh adamsgaard.dk -t '~/.local/bin/uu'
     93 	ssh debvm -t '~/.local/bin/uu'
     94 fi