-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·92 lines (81 loc) · 3.31 KB
/
install
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
#!/bin/bash
# Very convoluted but need to get the full path for the symlink
PWDS=$(pwd)
DIRS=$(dirname $0)
if [[ "$PWDS" != "$DIRS" ]]; then
pushd $(pwd)/$(basename $(dirname $0)) >/dev/null && SRC=$(pwd) && popd >/dev/null
pushd "$SRC" >/dev/null # work in the directory the script is in
else
SRC=$(pwd) && pushd "$(pwd)" >/dev/null
fi
# All of the simple thing that need a simple link
LINK="tmux.conf zshrc zshenv vimrc gitignore_global tmux"
for f in $LINK; do
if [ -e "$HOME/.$f" ]; then
if [[ $* == *--overwrite* || $IN_DEVCONTAINER = true ]]; then
echo "[ dotfiles ] $f exists – removing and relinking"
rm "$HOME/.$f" && ln -s -f "$SRC/$f" "$HOME/.$f"
else
echo "[ dotfiles ] $f exists – skipping"
fi
else
echo "[ dotfiles ] $f does not exist – linking"
# -f shouldn't be needed but vscode dev container has a weird bug
ln -s -f "$SRC/$f" "$HOME/.$f"
fi
done
# Optional Additions
# Set up git
if [[ $* == *--with-git-configs* ]]; then
if [[ ! -e "$HOME/.gitconfig" ]]; then
echo "[ gitconfig ] writing basic git config"
git config --global core.excludesfile "$SRC/.gitignore_global"
git config --global user.name "Barrett Olson"
git config --global user.email "barrett@barrettolson.com"
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global pull.rebase true
git config --global help.autocorrect 5
git config --global rebase.autostash true
# git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
else
echo "[ gitconfig ] gitconfig exists – skipping"
fi
else
echo "[ dotfiles ] Skipping writing basic git config (add --with-git-configs if desired)"
fi
# install fzf if in devcontaier (mac_stepup.sh handles this via brew for macOS)
if [[ $IN_DEVCONTAINER = true ]]; then
echo "[ dotfiles ] installing fzf for zsh"
git clone -q --depth 1 "https://github.com/junegunn/fzf.git" "$HOME/.fzf"
$HOME/.fzf/install --all --no-bash --no-fish
fi
# set up folder for our persistent vim logs
# echo "[ logs ] creating and setting permissions on log directories"
# mkdir -p "$HOME/.logs/vim-undodir"
#vim customization
if [[ $* == *--with-vim-plugins* ]]; then
# Install vundle
mkdir -p "$HOME/.vim/bundle"
rm -Rf "$HOME/.vim/bundle/"
git clone -q "https://github.com/VundleVim/Vundle.vim.git" "$HOME/.vim/bundle/Vundle.vim"
# Install vim plugins
vim +PluginInstall +qall
else
echo "[ dotfiles ] Skipping vim customizations (add --with-vim-plugins if desired)"
fi
# Install sqlite3 / zsh-histdb
if [[ $* == *--with-zsh-histdb* ]]; then
if grep "sqlite-history" "$HOME/.profile" >/dev/null; then
echo "[ zsh ] sqlite3 already installed"
else
echo "[ zsh ] installing sqlite3 hook"
git clone -q "https://github.com/larkery/zsh-histdb.git"
echo ". $SRC/zsh-histdb/history-timer.zsh" >>"$HOME/.profile"
echo "autoload -Uz add-zsh-hook" >>"$HOME/.profile"
mkdir "$HOME/.histdb"
chmod 700 "$HOME/.histdb"
fi
else
echo "[ dotfiles ] Skipping sqlite3/zsh-histdb install (add --with-zsh-histdb if desired)"
fi
popd >/dev/null