-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·145 lines (116 loc) · 2.99 KB
/
install.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/zsh
# Inlcude the helper script - Helper function for outputting information
# A log will offset the start to match success and errors
function log() {
echo -e "${@}"
}
# A generic log message
function info() {
echo -e "\033[0m -> ${@}"
}
# A success will provide a green indicator at the beggining of the output
success() {
echo -e "\033[38;5;2m -> \033[0m${@}"
}
# Error will retun a red indication at the beggining of the output
error() {
echo -e "\033[38;5;1m -> \033[0m${@}"
}
# Used to backup files
bkp() {
info "Backing up ${1}"
mv ${1} ${1}.bak
}
# Place will backup existing files and link new ones
place() {
filename=$(basename ${1})
source_file=$HOME/.dotfiles/$1
log "Installing ${filename}"
# If we passed a destination file, use it
# this will by the link target
destination=$HOME/.${1}
if [[ ! -z $2 ]]; then
destination=$HOME/.${2}
fi
# log a message
success "Copying '${source_file}' to '${destination}'"
# Check for an existing file and backup if it exists
if [[ -e ${destination} ]]; then
bkp ${destination}
fi
# link the file correctly
ln -s $source_file $destination
if [[ $? -eq 0 ]]; then
success "Placed ${filename}"
else
fail "Error placing ${filename}"
fi
echo ""
}
if [ ! -d $HOME/.bin ]; then
mkdir $HOME/.bin
fi
# Install dotfiles
if [ ! -d $HOME/.dotfiles ]; then
log "Downloading"
git clone https://github.com/mikemackintosh/dotfiles $HOME/.dotfiles
else
cd $HOME/.dotfiles
git pull --rebase
fi
# If we pass a module, do the love for it
if [[ ! -z $1 ]]; then
log "Selective-Install"
place $1 $2
exit
fi
# Get readlink
readlink $HOME/.zshrc | grep .dotfiles/zshrc > /dev/null
ZSH=$?
# Install if the links are not in place already
if [[ $ZSH -eq 1 ]]; then
# Create private dir
if [ ! -d "${HOME}/.private/" ]; then
mkdir $HOME/.private
touch $HOME/.private/nil
fi
# Place bin
place bin
# Place zsh
place zshrc
place zsh
place zsh-plugins
# Place curlrc
place curlrc
place psqlrc
# Place git
place git/gitconfig gitconfig
place git/gitconfig-osx gitconfig-osx
place git/gitignore gitignore
# Place tmux.conf
place tmux.conf
place hushlogin
place vimrc
else
log "Already installed. Skipping."
fi
if [[ $OSTYPE == darwin* ]]; then
# Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install zplug
source ~/.zsh/zplug/init.zsh
brew install git-delta
brew install the_silver_searcher
brew install jq
brew install go
brew install eza
brew install terraform
wget https://github.com/mikemackintosh/chrono/releases/download/v1.0.6/chrono-darwin-amd64
chmod +x ./chrono-darwin-amd64
mv ./chrono-darwin-amd64 $HOME/.bin/chrono
wget https://github.com/mikemackintosh/ninetails/releases/download/v1.0.4/ninetails-darwin-amd64
chmod +x ./ninetails-darwin-amd64
mv ./ninetails-darwin-amd64 $HOME/.bin/ninetails
fi
# Source the bash_profile we just installed
source ~/.zshrc