-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.dotbare.sh
executable file
·73 lines (58 loc) · 2 KB
/
.dotbare.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
DOTPATH=${DOTPATH:=".dotconfig"}
function requires {
command -v $@ >/dev/null 2>&1 || { echo >&2 "I require '$@' but it's not installed. Aborting."; exit 1; }
}
requires git
requires vim
requires zsh
requires curl
# determine which branch to use
if [ $# -eq 0 ]; then
if [ -d .git ]; then
echo "No branch provided, defaulting to current branch"
branch_name="$(git symbolic-ref HEAD 2>/dev/null)"
branch_name=${branch_name##refs/heads/}
echo $branch_name
else
echo "No branch provided, defaulting to 'master'"
branch_name='master'
fi
else
branch_name=$1
fi
if [ $# -eq 2 ]; then
repo="https://github.com/agotsis/dotfiles.git"
else
repo="[email protected]:agotsis/dotfiles.git"
fi
function config {
/usr/bin/git --git-dir=$HOME/$DOTPATH/ --work-tree=$HOME $@
}
mkdir -p $HOME/.config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config."
else
echo "Backing up pre-existing dot files."
config checkout $1 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} $HOME/.config-backup/{}
fi
git clone -b $branch_name --bare $repo $HOME/$DOTPATH || exit 1
config config status.showUntrackedFiles no
# install iterm2 integrations
curl -fLo https://iterm2.com/shell_integration/bash \
$HOME/.iterm2_shell_integration.bash
curl -fLo https://iterm2.com/shell_integration/zsh \
$HOME/.iterm2_shell_integration.zsh
# install plug
curl -fLo $HOME/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
mkdir $HOME/.vim/tmp
# install plugins
vim +'PlugInstall --sync' +qa
echo "export DOTPATH=\"$DOTPATH\"" >> ~/.zshenv
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --keep-zshrc --unattended
mv $HOME/.zshrc.pre-oh-my-zsh $HOME/.zshrc
# Use this when not installing mutt
# config ls-files --deleted -z | config update-index --assume-unchanged -z --stdin
config update-index --assume-unchanged .gitconfig
echo "Please update .gitconfig with the correct values."