diff --git a/makefile b/makefile new file mode 100644 index 0000000..99c0204 --- /dev/null +++ b/makefile @@ -0,0 +1,22 @@ +SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +cmd_exist = $(shell (command -v $(1) 1>&2 >/dev/null && echo true || echo false) ) + +install: | init update + +init: vim_init tmux_init +update: vim_update + +tmux_init: + $(info => Setting up tmux) + @ [ $(call cmd_exist,'tmux') ] \ + && ! [ -e ~/.tmux.conf ] \ + && ln -svf $(SRC_DIR)/tmux/tmux.conf ~/.tmux.conf \ + || echo " ~/.tmux.conf already exist. Skipping." + +vim_init: + @ $(MAKE) -C $(SRC_DIR)/vim init +vim_update: + @ $(MAKE) -C $(SRC_DIR)/vim update + +.PHONY: install update init foo diff --git a/vim/makefile b/vim/makefile new file mode 100644 index 0000000..2aad9cb --- /dev/null +++ b/vim/makefile @@ -0,0 +1,25 @@ +SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +TARGET_DIR := "~/.vim" +INSTALLED := $(shell command -v vim 1>&2 >/dev/null ; echo $$? ) + +install: | init update + +init: +ifneq ($(INSTALLED), 0) + $(error Vim not installed) +endif + $(info => Setting up vim) + @ [ -e ~/.vim ] && echo " ~/.vim already exist. Skipping." || "ln -svf $(SRC_DIR) $(TARGET_DIR)" + @ [ -e ~/.vim ] && echo " ~/.vimrc already exist. Skipping." || "ln -svf $(TARGET_DIR)/vimrc ~/.vimrc" + +update: + $(info => Updating vim) + @ curl -fsLo $(SRC_DIR)/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + @ [ $(INSTALLED) -ne 0 ] || vim +PlugInstall +PlugUpdate +qall + +remove: + @ [ -L ~/.vimrc ] && rm -f ~/.vimrc || echo "~/.vimrc is not a symbolic link. Skipping" + @ [ -L ~/.vim ] && rm -f ~/.vim || echo "~/.vim is not a symbolic link. Skipping" + + +.PHONY: install update init