Merge branch 'master' of git.jpatrick.io:james/dotfiles
This commit is contained in:
commit
e5123086cc
14
lib/helper/mk_link
Executable file
14
lib/helper/mk_link
Executable file
|
@ -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`"
|
23
lib/helper/report
Executable file
23
lib/helper/report
Executable file
|
@ -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
|
20
lib/helper/rm_link
Executable file
20
lib/helper/rm_link
Executable file
|
@ -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
|
18
lib/makefile
Normal file
18
lib/makefile
Normal file
|
@ -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)
|
32
lib/shared.mk
Normal file
32
lib/shared.mk
Normal file
|
@ -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
|
46
makefile
46
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)
|
||||
|
|
|
@ -7,4 +7,3 @@ Host git.jpatrick.io
|
|||
|
||||
Host *
|
||||
UseRoaming no
|
||||
|
||||
|
|
23
ssh/makefile
Normal file
23
ssh/makefile
Normal file
|
@ -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."
|
22
sway/makefile
Normal file
22
sway/makefile
Normal file
|
@ -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)
|
21
tmux/makefile
Normal file
21
tmux/makefile
Normal file
|
@ -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)
|
19
tridactyl/makefile
Normal file
19
tridactyl/makefile
Normal file
|
@ -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)
|
26
vim/makefile
26
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)
|
||||
|
|
|
@ -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()
|
||||
|
|
24
waybar/makefile
Normal file
24
waybar/makefile
Normal file
|
@ -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
|
Loading…
Reference in New Issue
Block a user