-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·52 lines (52 loc) · 1.83 KB
/
setup.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
#!/bin/bash
for CMD in realpath; do
hash $CMD 2>/dev/null || {
echo "I require $CMD but it is not installed. Aborting."
return 1
exit 1
}
done
git submodule update --init
git config --global alias.l "log --graph --abbrev-commit --decorate --date=relative --format='%C(auto)%h - %C(bold green)(%ar)%C(reset)%C(auto) %s - %C(bold)%an%C(reset)%C(auto)%d'"
git config --global alias.lc '!f() {
: git log
if [ $# -eq 0 ]; then
f HEAD @{upstream} || f HEAD origin/HEAD;
elif [ $# -eq 1 ]; then
f HEAD $1;
else
git l "$@" ^$(git merge-base -a --octopus "$@")^@;
fi;
}; f'
git config --global alias.la '!f() { git lc $(git rev-parse HEAD --all "$@"); }; f'
git config --global alias.lb '!f() { git lc $(git rev-parse HEAD --branches="$@"); }; f'
git config --global alias.lt '!f() { git lc $(git rev-parse HEAD --tags="$@"); }; f'
git config --global alias.lr '!f() { git lc $(git rev-parse HEAD --remotes="$@"); }; f'
git config --global core.excludesfile "~/.cvsignore"
git config --global core.pager "less -FXRS"
git config --global url.ssh://[email protected]/.pushinsteadof git://github.com/
git config --global url.ssh://[email protected]/.pushinsteadof https://github.com/
for f in \
bashrc \
config/nvim \
cvsignore \
screenrc \
tmux.conf \
vim \
vimrc \
; do
DOTFILES="$(realpath --relative-to="$(dirname "${HOME}/.${f}")" "$(dirname "${BASH_SOURCE[0]}")")"
source="$HOME/.$f"
target="${DOTFILES}/$f"
if [ -e $source ]; then
if [ "$(readlink $source)" = "$target" ]; then
echo "$f already installed"
continue
fi
echo $source exists, moving it to $source.bak
mv $source $source.bak
fi
mkdir -p $(dirname $source)
ln -sf $target $source
echo "$f installed ($source -> target)"
done