-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·51 lines (41 loc) · 1.32 KB
/
install.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
#!/bin/bash
set -euxo pipefail
DOTFILE_DIR="$(cd $(dirname ${BASH_SOURCE}); pwd)"
pushd "${DOTFILE_DIR}"
git submodule update --init
popd
BACKUP_DIR=~/backup
mkdir -p "${BACKUP_DIR}"
dotfiles=(".bash_aliases" ".gitconfig" ".vimrc")
for dotfile in "${dotfiles[@]}"; do
if [[ -f ~/"${dotfile}" ]]; then
if [[ -L ~/"${dotfile}" ]]; then
if [[ "$(readlink ~/${dotfile})" == "${DOTFILE_DIR}/${dotfile}" ]]; then
continue
else
unlink "~/${dotfile}"
fi
else
mv "~/${dotfile}" "${BACKUP_DIR}"
fi
fi
ln -s "${DOTFILE_DIR}/${dotfile}" ~
done
if [[ (! -f ~/.bashrc) || (-z "$(grep "source ${DOTFILE_DIR}/.bashrc" ~/.bashrc)") ]]; then
echo "source ${DOTFILE_DIR}/.bashrc" >> ~/.bashrc
fi
if [[ -z "$(grep ". ~/.bash_aliases" ~/.bashrc)" ]]; then
cat << EOF >> ~/.bashrc
if [[ -f ~/.bash_aliases ]]; then
. ~/.bash_aliases
fi
EOF
fi
if [[ "$(which fzf | wc -l)" -eq 0 ]]; then
${DOTFILE_DIR}/.fzf/install --key-bindings --completion --update-rc
fi
if [[ "$(which diff-highlight | wc -l)" -gt 0 ]]; then
git config -f ~/.gitconfig.pager pager.log "diff-highlight | less"
git config -f ~/.gitconfig.pager pager.show "diff-highlight | less"
git config -f ~/.gitconfig.pager pager.diff "diff-highlight | less"
fi