-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
executable file
·91 lines (74 loc) · 2.53 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
#!/usr/bin/env zsh -e
# Requirements: iterm2 and zsh, homebrew, python3, python-pip
# Set zsh as default: chsh -s /bin/zsh
MAC_DEPS=(
bat # cat++
exa # ls++
fd # find++
neovim # vim++
ripgrep # grep++
fzf # fuzzy finder - https://github.com/junegunn/fzf
tree # for fzf previews of dir trees
git-delta # improved diff viz - https://github.com/dandavison/delta
clang-format
gh
openssl
wget
reattach-to-user-namespace # tmux access to clipboard: https://blog.carbonfive.com/copying-and-pasting-with-tmux-2-4
)
BIN_DIR=~/bin
function brewIn() {
if brew ls --versions "$1"; then
brew upgrade "$1"
else
brew install "$1"
fi
}
function install_deps() {
echo "\n#### Installing pip dependencies ####\n"
pip install --upgrade pre-commit tabcompletion cpplint ptpython pdbpp || true
echo "\n#### Installing brew dependencies ####\n"
brew update || true
for dep in ${MAC_DEPS}; do
brewIn ${dep} || true
done
$(brew --prefix)/opt/fzf/install --all || true # fzf key-bindings and fuzzy completion
echo "\n#### Installing on-my-zsh ####\n"
# Install oh-my-zsh into current dir. We'll symlink later to homedir.
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | ZSH=.oh-my-zsh sh || true
echo "\n#### Installing antigen ####\n"
# Install antigen (for easier third-party plugin management than oh-my-zsh) into current dir.
# We'll symlink later to homedir.
curl -L git.io/antigen > .antigen.zsh
}
function symlink_dotfiles() {
if [ "$#" -ne 1 ]; then
echo "Usage: ${0} <target_dir>"
return
fi
echo "\n#### Setting up symlinks ####\n"
target_dir="${1}"
# Symlink dotfiles to target_dir
for f in $(ls -a | grep '^\.'); do
if ! [[ ($f == .) || ($f == ..) || ($f =~ "^\.git.*") || ($f =~ "\.sw.*") ]]; then
echo "Symlink: ${target_dir}/${f} -> $(pwd)/${f}"
ln -sF $(pwd)/${f} ${target_dir}/
fi
done
}
function download_binary() {
if [ "$#" -lt 1 ]; then
echo "Usage: ${0} <release_url.tar.gz> [<num_leading_path_elements_to_skip>]"
return
fi
url="${1}"
strip_components="${2:-0}"
echo "Extracting ${url} to ${BIN_DIR}"
mkdir -p ${BIN_DIR}
wget -qO- ${url} | tar xz - -C ${BIN_DIR}/ --strip-components=${strip_components}
}
git submodule update --init --recursive --remote
install_deps
symlink_dotfiles ~ # Symlink dotfiles to homedir
git config --global include.path ~/.delta.gitconfig # git-delta config
echo "\n#### Done setting up dotfiles! ####\n"