-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
185 lines (154 loc) · 4.46 KB
/
Copy pathsetup.sh
File metadata and controls
185 lines (154 loc) · 4.46 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env bash
COLOR_DEBUG='\033[1;33m'
COLOR_INFO='\033[1;34m'
COLOR_SUCCESS='\033[1;32m'
COLOR_ERROR='\033[1;31m'
COLOR_RESET='\033[0m'
PREFIX="-----> "
CURRENT_DIR=$(pwd)
DOTFILES_DIR=${CURRENT_DIR}/dotfiles
_debug() {
printf "${COLOR_DEBUG}${PREFIX}[DEBUG] $1${COLOR_RESET}\n"
}
_info() {
printf "${COLOR_INFO}${PREFIX}$1${COLOR_RESET}\n"
}
_success() {
printf "${COLOR_SUCCESS}${PREFIX}$1${COLOR_RESET}\n"
}
_error() {
printf "${COLOR_ERROR}${PREFIX}$1${COLOR_RESET}\n"
}
_done() {
_info "Done"
}
_download() {
from=$1
to=$2
curl --create-dirs -LsSo $to $from
}
install_essentials_osx() {
osx_essentials=(
"--cask aws-vault"
"bash"
"bash_completion"
"coreutils"
"curl"
"direnv"
"findutils"
"fzf"
"gnupg"
"jq"
"neovim"
"openssh"
"pass"
"pinentry-mac"
"pre-commit"
"pwgen"
"ripgrep"
"ruff"
"tfenv"
"tmux"
"tree"
"wget"
"ykman"
)
if [[ ! $(which brew) ]]; then
_error "brew is not installed. Exiting..."
exit 1
fi
for item in "${osx_essentials[@]}"; do
_info "Installing ${item}"
brew install ${item} > /dev/null
done
_done
}
remove_old_files() {
_info "Removing old stuff..."
_info "Removing symlinks and creating backups of regular files"
for item in "${DOTFILES_DIR}"/*; do
# Skip over dirs
[[ -d "${item}" ]] && continue
filename=$(basename ${item})
# if a .dotfile symlink exists remove it
# if a non-symlink .dotfile exists back it up
if [[ -L ~/.${filename} ]]; then
_info "Removing symlink ${filename}"
rm ~/.${filename}
elif [[ -f ~/.${filename} ]]; then
_info "Creating backup for ${filename} at ~/${filename}.bak"
mv ~/.${filename} ~/.${filename}.bak
fi
done
_done
}
create_config_symlinks() {
_info "Creating config symlinks..."
# use the gnu version of cp, installed by coreutils
# Arguments:
#
# -r : recursive
# -s : symbolic link
# -v : verbose
# -i : interactive (ask if file exists)
# -b : backup
# -S .bak : set the backup suffix
#
gcp -rsvib -S .bak ${CURRENT_DIR}/config/* ${HOME}/.config/
_done
}
configure_neovim() {
NEOVIM_CONFIG_DIR="${HOME}/.config/nvim"
NEOVIM_PLUG_VERSION=0.10.0
NEOVIM_PLUG_URL="https://raw.githubusercontent.com/junegunn/vim-plug/${NEOVIM_PLUG_VERSION}/plug.vim"
_info "Downloading vim-plug ${NEOVIM_PLUG_VERSION}"
_download ${NEOVIM_PLUG_URL} ${HOME}/.local/share/nvim/site/autoload/plug.vim
_done
_info "Installing vim plugins..."
nvim +PlugInstall +qall
}
configure_git() {
_info "Downloading latest git-completion and git-prompt..."
_download https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash ${HOME}/.git-completion.bash
_download https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh ${HOME}/.git-prompt.sh
_done
}
configure_tmux() {
if [[ ! -d ${HOME}/.tmux/plugins/tpm ]]; then
echo "${prefix} Cloning tmux-plugins..."
git clone https://github.com/tmux-plugins/tpm ${HOME}/.tmux/plugins/tpm
fi
}
create_dotfile_symlinks() {
_info "Creating symlinks..."
for item in "${DOTFILES_DIR}"/*; do
# Skip over dirs
[[ -d "${item}" ]] && continue
filename=${HOME}/.$(basename ${item})
if [[ -f ${filename} ]]; then
_info "${filename} exists, skipping"
continue
fi
_info "Symlinking ${filename} to ${item}"
ln -s ${item} ${filename}
done
}
setup_gpg() {
local key_id="FD3D7BD0882FE25C1B9B415BF393DA8310B040C1"
gpg --keyserver $(dig +short keyserver.ubuntu.com | head -n 1) --recv-keys ${key_id}
echo "enable-ssh-support" > ${HOME}/.gnupg/gpg-agent.conf
echo "pinentry-program /opt/homebrew/bin/pinentry-mac" >> ${HOME}/.gnupg/gpg-agent.conf
echo "standard-resolver" > ${HOME}/.gnupg/dirmngr.conf
_success "Updated gpg configuration \nTrust the key by running:\n\tgpg --edit-key ${key_id}\nand then pass 'trust -> 5 -> y -> quit'"
}
install_essentials_osx
remove_old_files
create_config_symlinks
configure_neovim
configure_git
configure_tmux
create_dotfile_symlinks
setup_gpg
_success "Setup complete!"
_success "Reload your shell for changes to take place..."
exit 0