STOWED = bin git ruby tmux vim zsh alacritty

all: install

install: plug-vim
	stow $(STOWED)

uninstall:
	stow -D $(STOWED)

plug-vim:
	if test ! -f ~/.vim/autoload/plug.vim ; then \
		curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
				https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim ; \
	fi

rbenv: rbenv-base rbenv-build

rbenv-base:
	if test ! -d ~/.rbenv ; then \
		git clone https://github.com/rbenv/rbenv.git ~/.rbenv ; \
	fi

rbenv-build:
	if test ! -d ~/.rbenv/plugins/ruby-build ; then \
		git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build ; \
	fi

update: update-repo

update-repo:
	git pull --rebase

clean:
	rm -f $$HOME/bin/,
	bash remove-symlinks

mac:
	sudo mv /etc/{zprofile,zprofile.old}