-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
108 lines (86 loc) · 2.45 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
set -e
set -u
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
reset=`tput sgr0`
## printing functions ##
function gecho {
echo "${green}[message] $1${reset}"
}
function yecho {
echo "${yellow}[note] $1${reset}"
}
function wecho {
# red, but don't exit 1
echo "${red}[error] $1${reset}"
}
function recho {
echo "${red}[error] $1${reset}"
exit 1
}
## install functions ##
# look for command line tool, if not install via homebrew
function install_brew {
(command -v $1 > /dev/null && gecho "$1 found...") ||
(yecho "$1 not found, installing via homebrew..." && brew install $1)
}
# check for pre-req, fail if not found
function check_preq {
(command -v $1 > /dev/null && gecho "$1 found...") ||
recho "$1 not found, install before proceeding."
}
# function for linking dotfiles
function linkdotfile {
file="$1"
if [ ! -e ~/$file -a ! -L ~/$file ]; then
yecho "$file not found, linking..." >&2
ln -s ~/dotfiles2/$file ~/$file
else
gecho "$file found, ignoring..." >&2
fi
}
# are we in right directory?
[[ $(basename $(pwd)) == "dotfiles2" ]] ||
recho "doesn't look like you're in dotfiles2/"
# check that the key pre-requisites are met:
check_preq gcc
check_preq "command -v ~/anaconda/bin/conda"
# install Homebrew main programs if on a mac
if [[ "$(uname)" == "Darwin" ]]; then
check_preq brew
install_brew rg
install_brew tmux
install_brew nvim
fi
# link over git stuff
linkdotfile .gitconfig
# link config directory (including NeoVim settings)
linkdotfile .config
# linkover .condarc
linkdotfile .condarc
# link manual zsh
linkdotfile .zshrc
## link antigen
#if [ ! -e ~/.antigen.zsh ]; then
# yecho "~/.antigen not found, downloading..."
# curl -L git.io/antigen > ~/.antigen.zsh
#else
# gecho "~/.antigen.zsh found."
#fi
#linkdotfile .antigenrc
# get antidote for zsh
git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote
# create a global Git ignore file
if [ ! -e ~/.global_ignore ]; then
yecho "~/.global_ignore not found, curling from Github..." >&2
curl \
https://raw.githubusercontent.com/github/gitignore/master/Global/Vim.gitignore \
https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore \
> ~/.global_ignore 2> /dev/null
git config --global core.excludesfile ~/.global_ignore &&
yecho "[message] adding ignore file to Git..." >&2
else
gecho "~/.global_ignore found, ignoring..." >&2
fi