From cd39fb13dc1efdf62ff2a339a48cc708829f6322 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sun, 14 Apr 2019 03:26:21 -0400 Subject: [PATCH] Added makefiles for both vim and dotfiles as a whole. Rough draft at this point but should work. --- makefile | 22 ++++++++++++++++++++++ vim/makefile | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 makefile create mode 100644 vim/makefile 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