-
Notifications
You must be signed in to change notification settings - Fork 7
/
install-dotfiles
executable file
·41 lines (35 loc) · 1.2 KB
/
install-dotfiles
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
#!/bin/bash
###############################################################################
# Install dotfiles as a bare git repository. Conflicting files found during #
# installation are moved to $HOME/dotfiles.backup. #
# Dependencies: git #
###############################################################################
set -o errexit
export GIT_WORK_TREE="$HOME"
export GIT_DIR="$GIT_WORK_TREE/.dotfiles"
backupdir="$GIT_WORK_TREE/dotfiles.backup"
repository="https://github.com/potamides/dotfiles.git"
exclude=(".gitmodules" "README.md" "LICENSE" ".local/bin/install-*")
function clone(){
cd "$GIT_WORK_TREE"
git clone --bare "$repository" "$GIT_DIR"
}
function backup(){
for file in $(git ls-tree -r --name-only HEAD); do
if [[ -e "$file" ]]; then
mkdir -p "$backupdir"
mv "$file" "$backupdir"
fi
done
}
function install(){
git checkout
git submodule update --init
git config status.showUntrackedFiles no
git config core.worktree "$GIT_WORK_TREE"
git config alias.edit '!env -C "${GIT_PREFIX:-.}" $EDITOR'
git sparse-checkout set "*" "${exclude[@]/#/\!}" --no-cone
}
clone
backup
install