diff --git a/README.md b/README.md new file mode 100644 index 0000000..557db03 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Hello World diff --git a/lib/helper/mk_link b/lib/helper/mk_link new file mode 100755 index 0000000..50a3197 --- /dev/null +++ b/lib/helper/mk_link @@ -0,0 +1,14 @@ +#! env zsh +REPORT=`dirname $0`/report + +if [ -z "$1" ] || [ -z "$2" ] ; then + $REPORT error "ERROR: Both to and from string must be defined.\n source: $1 \n symlnk: $2" + exit +fi + +if [[ -e $2 ]] ; then + $REPORT warn "$2 already exist. Skipping." + exit +fi + +$REPORT info "Symlinked `ln -svf $1 $2`" diff --git a/lib/helper/report b/lib/helper/report new file mode 100755 index 0000000..75794b8 --- /dev/null +++ b/lib/helper/report @@ -0,0 +1,23 @@ +#! env zsh +R='\033[0;31m' +Y='\033[0;33m' +G='\033[0;32m' +NC='\033[0m' # No Color + +format(){ + case $1 in + "error") echo -e "$R x $2$NC";; + "warn") echo -e "$Y ⚠ $2$NC";; + "info") echo -e "$G ✔ $2$NC";; + *) echo -e "$1: $2";; + esac +} + +if [[ -z $2 ]] ; then + case "$LAST_RETURN" in + 0) format info $1;; + *) format error "FAILURE DURING: \"$1\"";; + esac +else + format $1 $2 +fi diff --git a/lib/helper/rm_link b/lib/helper/rm_link new file mode 100755 index 0000000..fa951d4 --- /dev/null +++ b/lib/helper/rm_link @@ -0,0 +1,20 @@ +#! env zsh +REPORT=`dirname $0`/report + +if [[ -z $1 ]] ; then + $REPORT error "ERROR: Symlink to delete does not exist.\n symlink: $1" + exit +fi + +if ! ( [[ -e $1 ]] || [[ -L $1 ]] ) ; then + $REPORT warn "$1 does not exist." + exit +fi + +if [[ ! -L $1 ]] ; then + $REPORT warn "$1 is not a symbolic link. Skipping." + exit +fi + +$REPORT info "Deleting $1" +rm $1 diff --git a/lib/makefile b/lib/makefile new file mode 100644 index 0000000..7658c87 --- /dev/null +++ b/lib/makefile @@ -0,0 +1,18 @@ + +SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +GIT_HOOK_SRC = $(SRC_DIR)/post-merge +GIT_HOOK_TARGET = $(abspath $(SRC_DIR)/..)/.git/hooks/post-merge + +include ../lib/shared.mk + +install: | init update + +init: + $(info => Setting up githook) + $(report) info "Symlinked `ln -svf $(GIT_HOOK_SRC) $(GIT_HOOK_TARGET)`" + +update: + +remove: + $(info => Removing Githook) + $(rm_link) $(GIT_HOOK_TARGET) diff --git a/bin/post-merge b/lib/post-merge similarity index 100% rename from bin/post-merge rename to lib/post-merge diff --git a/lib/shared.mk b/lib/shared.mk new file mode 100644 index 0000000..ebde197 --- /dev/null +++ b/lib/shared.mk @@ -0,0 +1,32 @@ +# This will make heavy use of the "$+commands[cmd]" function in bash. Make sure its installed. +_SHELL := $(shell which zsh ) +ifndef _SHELL + $(error ZSH is not installed on this machine. This makefile requires ZSH features) +endif +SHELL := $(_SHELL) + + +# Helper scripts for setting up and taking down links. +LIB_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +mk_link := $(LIB_DIR)/helper/mk_link +rm_link := $(LIB_DIR)/helper/rm_link +report := LAST_RETURN=$$? $(LIB_DIR)/helper/report +cmd_exist = $(shell (($$+commands[$1])) && echo true || echo false ) + +# Shortcut for the XDG dir if it exist. default to ~/.confg +XDG_DIR := $${XDG_CONFIG_DIR:-~/.config} + +# Some things will OS specific. +# With this you can use `$(IS_MAC) && echo "I'm a Mac" || echo "I'm not a Mac"` +ifeq ($(shell uname), Darwin) + IS_MAC=true +else + IS_LINUX=true +endif +IS_MAC?=false +IS_LINUX?=false + +# TURN THIS OFF FOR DEBUGGING +MAKEFLAGS += --silent + +.PHONY: install update init remove diff --git a/makefile b/makefile index 2dce1ea..3690f46 100644 --- a/makefile +++ b/makefile @@ -1,33 +1,27 @@ 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 +include lib/shared.mk -init: vim_init tmux_init ssh_init waybar_init - @ ln -svf $(SRC_DIR)/bin/post-merge $(SRC_DIR)/.git/hooks/post-merge -update: vim_update +define recursive_make + for i in */makefile; do; \ + echo "`dirname $$i` " ; \ + $(MAKE) -C $(SRC_DIR)/`dirname $$i` $1 ; \ + echo "" ; \ + done +endef -ssh_init: - $(info => Setting up ssh config) - @ ! [ -e ~/.ssh/config ] \ - && ln -svf $(SRC_DIR)/ssh/config ~/.ssh/config \ - || echo " ~/.ssh/config already exist. Skipping." +install: + $(info Initalizing) + $(call recursive_make,install) -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." +init: + $(info Initalizing) + $(call recursive_make,init) -waybar_init: - @ [ $(call cmd_exist,'waybar') ] \ - && ! [ -e ~/.config/waybar ] \ - && ln -svf $(SRC_DIR)/waybar ~/.config/waybar \ - || echo " ~/.waybar.conf already exist. Skipping." -vim_init: - @ $(MAKE) -C $(SRC_DIR)/vim init -vim_update: - @ $(MAKE) -C $(SRC_DIR)/vim update +update: + $(info Updating) + $(call recursive_make,update) -.PHONY: install update init foo +remove: + $(info Removing) + $(call recursive_make,remove) diff --git a/ssh/config b/ssh/config index 9e8110a..6f47fa2 100644 --- a/ssh/config +++ b/ssh/config @@ -7,4 +7,3 @@ Host git.jpatrick.io Host * UseRoaming no - diff --git a/ssh/makefile b/ssh/makefile new file mode 100644 index 0000000..df90474 --- /dev/null +++ b/ssh/makefile @@ -0,0 +1,23 @@ +SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +SOURCE := $(SRC_DIR)/config +TARGET := ~/.ssh/config + +include ../lib/shared.mk + +install: | init update + +init: + $(info => Setting up ssh) + $(mk_link) $(SOURCE) $(TARGET) + [ ! -e ~/.ssh/git.jpatrick.io ] \ + && echo "No key for git.jpatrick.io. Generating" \ + && ( ssh-keygen -t ed25519 -C "`hostname`: `date`" -f ~/.ssh/git.jpatrick.io -N "" \ + ; $(report) "Key generation" ) \ + ; true + +update: + +remove: + $(info => Remvoing ssh) + $(rm_link) $(TARGET) + $(report) warn "NOTE: All prior keys still remain." diff --git a/sway/makefile b/sway/makefile new file mode 100644 index 0000000..d3cf0e5 --- /dev/null +++ b/sway/makefile @@ -0,0 +1,22 @@ +SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +include ../lib/shared.mk +TARGET := $(XDG_DIR)/sway + +install: | init update + +init: +ifeq ($(call cmd_exist,sway), true) + $(info => Setting up sway) + $(mk_link) $(SRC) $(TARGET) +endif + +update: +ifeq ($(call cmd_exist,swaymsg), true) + $(info => Reloading sway) + swaymsg reload ; $(report) "sway reload" +endif + +remove: + $(info => Remvoing sway) + $(rm_link) $(TARGET) diff --git a/tmux/makefile b/tmux/makefile new file mode 100644 index 0000000..c176759 --- /dev/null +++ b/tmux/makefile @@ -0,0 +1,21 @@ +SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +SOURCE := $(SRC_DIR)/tmux.conf +TARGET := ~/.tmux.conf + +include ../lib/shared.mk + +install: | init update + +init: +ifeq ($(call cmd_exist,tmux), true) + $(info => Setting up tmux) + $(mk_link) $(SOURCE) $(TARGET) +else + $(report) warn "tmux not installed" +endif + +update: + +remove: + $(info => Remvoing tmux config) + @ $(rm_link) $(TARGET) diff --git a/tridactyl/makefile b/tridactyl/makefile new file mode 100644 index 0000000..bd98090 --- /dev/null +++ b/tridactyl/makefile @@ -0,0 +1,19 @@ +SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +include ../lib/shared.mk +TARGET := $(XDG_DIR)/tridactyl + + +install: | init update + +init: +ifeq ($(shell $(call cmd_exist,firefox) || $(IS_MAC) ; echo $$? ), 0) + $(info => Setting up Tridacyl) + $(mk_link) $(SRC) $(TARGET) +endif + +update: + +remove: + $(info => Remvoing tridactyl ) + $(rm_link) $(TARGET) diff --git a/vim/makefile b/vim/makefile index 5b7fa08..0b73f7d 100644 --- a/vim/makefile +++ b/vim/makefile @@ -1,25 +1,29 @@ SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) TARGET_DIR := ~/.vim -INSTALLED := $(shell command -v vim 1>&2 >/dev/null ; echo $$? ) +PLUG_URL := https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +PLUG_PATH := $(SRC_DIR)/autoload/plug.vim + +include ../lib/shared.mk install: | init update init: -ifneq ($(INSTALLED), 0) +ifneq ($(call cmd_exist,vim), true) $(error Vim not installed) endif $(info => Setting up vim) - @ [ -e ~/.vim ] && echo " ~/.vim already exist. Skipping." || ln -svf $(SRC_DIR) $(TARGET_DIR) - @ [ -e ~/.vimrc ] && echo " ~/.vimrc already exist. Skipping." || ln -svf $(TARGET_DIR)/vimrc ~/.vimrc + @ $(mk_link) $(SRC_DIR) $(TARGET_DIR) + @ $(mk_link) $(SRC_DIR)/vimrc ~/.vimrc update: +ifneq ($(call cmd_exist,vim), true) + $(error Vim not installed) +endif $(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 + curl -fsLo $(PLUG_PATH) $(PLUG_URL) ; $(report) "vim plug setup" + vim +PlugInstall +PlugUpdate +qall ; $(report) "downloading/updating plugins" 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 + $(info => Removing vim config) + @ $(rm_link) ~/.vimrc + @ $(rm_link) $(TARGET_DIR) diff --git a/vim/vimrc.d/plugins.vim b/vim/vimrc.d/plugins.vim index a05ffb2..ec21cd9 100644 --- a/vim/vimrc.d/plugins.vim +++ b/vim/vimrc.d/plugins.vim @@ -69,4 +69,57 @@ for fpath in split(globpath('~/.vim/plug.d/', '*.vim'), '\n') exe 'source' fpath endfor +" CTRL-P + let g:ctrlp_cmd = 'CtrlPMixed' + let g:ctrlp_working_path_mode = 'ra' + if executable('ag') + let g:ctrlp_user_command = 'ag -Q -l --nocolor --hidden -g "" %s' + endif + +" VIM-AIRPLAINE + let g:airline_powerline_fonts = 1 + if !exists('g:airline_symbols') + let g:airline_symbols = {} + endif + let g:airline_left_sep = '⮀' + let g:airline_right_sep = '⮂' + let g:airline_right_alt_sep = '⮃' + let g:airline_left_alt_sep = '⮁' + let g:airline_symbols.branch = '⭠' + let g:airline_symbols.linenr= '⭡' + let g:airline_symbols.readonly= '⭤' + let g:airline#extensions#tabline#enabled = 1 + let g:airline#extensions#tabline#left_sep = ' ' + let g:airline#extensions#tabline#left_alt_sep = '|' + let g:airline_theme = 'powerlineish' + set laststatus=2 + set ttimeoutlen=50 + +" RAINBOW_PARENTHESE + let g:rbpt_colorpairs = [ + \ ['brown', 'RoyalBlue3'], + \ ['Darkblue', 'SeaGreen3'], + \ ['darkgray', 'DarkOrchid3'], + \ ['darkgreen', 'firebrick3'], + \ ['darkcyan', 'RoyalBlue3'], + \ ['darkred', 'SeaGreen3'], + \ ['darkmagenta', 'DarkOrchid3'], + \ ['brown', 'firebrick3'], + \ ['gray', 'RoyalBlue3'], + \ ['black', 'SeaGreen3'], + \ ['darkmagenta', 'DarkOrchid3'], + \ ['Darkblue', 'firebrick3'], + \ ['darkgreen', 'RoyalBlue3'], + \ ['darkcyan', 'SeaGreen3'], + \ ['darkred', 'DarkOrchid3'], + \ ['red', 'firebrick3'], + \ ] + let g:rbpt_max = 16 + au VimEnter * RainbowParenthesesToggle + au Syntax * RainbowParenthesesLoadRound + au Syntax * RainbowParenthesesLoadSquare + au Syntax * RainbowParenthesesLoadBraces + + + call plug#end() diff --git a/waybar/makefile b/waybar/makefile new file mode 100644 index 0000000..c108e00 --- /dev/null +++ b/waybar/makefile @@ -0,0 +1,24 @@ +SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +include ../lib/shared.mk +TARGET := $(XDG_DIR)/waybar + +install: | init update + +init: +ifeq ($(call cmd_exist,waybar), true) + $(info => Setting up waybar) + $(mk_link) $(SRC) $(TARGET) +endif + +update: +ifeq ($(call cmd_exist,swaymsg), true) + $(info => Reloading sway) + swaymsg reload ; $(report) "sway reload" +endif + +remove: + $(info => Removing waybar) + @ $(rm_link) $(TARGET) + +.PHONY: install update init remove