-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-dotfiles.sh
executable file
·39 lines (35 loc) · 1.26 KB
/
install-dotfiles.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
#!/bin/bash
#
# Install dotfiles on new machine
#
export DOTFILES=${DOTFILES:-".dotfiles"}
if [ -e "${HOME}/${DOTFILES}" ]; then
echo "${HOME}/${DOTFILES} already exists !"
exit 1
fi
# Clone repo and set it up
git clone --bare [email protected]:Twanislas/dotfiles.git "${HOME}/${DOTFILES}"
git --git-dir="${HOME}/${DOTFILES}" --work-tree="${HOME}" config --local core.bare no
git --git-dir="${HOME}/${DOTFILES}" --work-tree="${HOME}" config --local core.worktree "${HOME}"
git --git-dir="${HOME}/${DOTFILES}" --work-tree="${HOME}" config --local status.showUntrackedFiles no
git --git-dir="${HOME}/${DOTFILES}" --work-tree="${HOME}" config --local core.sparsecheckout true
{
echo '*'
echo '.*'
echo '/*'
} >> "${HOME}/${DOTFILES}"/info/exclude
{
echo '/*'
echo '!README.md'
echo '!LICENCE'
echo '!.github'
echo '!.gitleaks.toml'
} >> "${HOME}/${DOTFILES}"/info/sparse-checkout
ln -sf "${HOME}/.bin/gitleaks-pre-commit-hook" "${HOME}/${DOTFILES}"/hooks/pre-commit
# Pull files
git --git-dir="${HOME}/${DOTFILES}" --work-tree="${HOME}" checkout -f
git --git-dir="${HOME}/${DOTFILES}" --work-tree="${HOME}" submodule update --recursive --init
# Change default shell to Zsh
sudo chsh -s "$(which zsh)" "$USER"
# Spawn a new shell
exec "$(which zsh)"