From 649b1581667967632a7e41db07de545efe8475d7 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:07:48 -0400 Subject: [PATCH 1/8] relocated bin -> lib lib will be more accurate since a lot of these aren't going to be bin stubs. --- {bin => lib}/post-merge | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {bin => lib}/post-merge (100%) diff --git a/bin/post-merge b/lib/post-merge similarity index 100% rename from bin/post-merge rename to lib/post-merge From e49934c99d510c1b4294d89549cbb2a284ebb7bf Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:09:36 -0400 Subject: [PATCH 2/8] Adding shared makefile logic and helper scripts Shared logic can be imported via `include ../lib/shared.mk` Helper functions include 3 current opperations 1. mk_link:: This will create a symbolic link if the file doesn't already exist. 2. rm_link:: Will remove the link if it is a symlink. 3. report :: This color codes the status of a message and adds a leading symbol. report also can be called with `LAST_RETURN=$? report "message"` and will expand this to be either `report info "message"` Or `report error "message"` based on the last return value. Current status are info, warn, and error. --- lib/helper/mk_link | 14 ++++++++++++++ lib/helper/report | 23 +++++++++++++++++++++++ lib/helper/rm_link | 20 ++++++++++++++++++++ lib/shared.mk | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100755 lib/helper/mk_link create mode 100755 lib/helper/report create mode 100755 lib/helper/rm_link create mode 100644 lib/shared.mk 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/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 From d26d20d8d6a57f8feaa3fa28536ebde7bd19fd99 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:15:45 -0400 Subject: [PATCH 3/8] Simplified base level make to recursive make command. It will look for all first level child `makefile`, and run assigned target. This is equivalent to running: ```shell for i in */makefile; do make -C $i $target done ``` --- makefile | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) 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) From f90e026e492154e63d25c28ae2c4c0fbaa053e55 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:19:10 -0400 Subject: [PATCH 4/8] Added missing functionality that was implemented in prior vimrc file. Primary help for CTRL-P VIM-AIRPLANE, and RAINBOW_PARENTHESE --- vim/vimrc.d/plugins.vim | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) 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() From 159e2d6b1b1abfc5492329d0fe97cc2871b997f9 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:20:21 -0400 Subject: [PATCH 5/8] Remove empty trailing line. --- ssh/config | 1 - 1 file changed, 1 deletion(-) 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 - From 7bd836b67cb789fa9c223f64b8749105e98a4beb Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:21:00 -0400 Subject: [PATCH 6/8] Updated vim to current makefile format. --- vim/makefile | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) 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) From 30b0cc68aed155f84741cd33e5f3747e58f143b2 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:21:33 -0400 Subject: [PATCH 7/8] Adding makefile for all current configurations. --- lib/makefile | 18 ++++++++++++++++++ ssh/makefile | 23 +++++++++++++++++++++++ sway/makefile | 22 ++++++++++++++++++++++ tmux/makefile | 21 +++++++++++++++++++++ tridactyl/makefile | 19 +++++++++++++++++++ waybar/makefile | 24 ++++++++++++++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 lib/makefile create mode 100644 ssh/makefile create mode 100644 sway/makefile create mode 100644 tmux/makefile create mode 100644 tridactyl/makefile create mode 100644 waybar/makefile 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/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/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 From aec79627c574303999156867c55a48382e98ba80 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Sat, 27 Apr 2019 18:23:10 -0400 Subject: [PATCH 8/8] Adding placeholder readme file. --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md 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