-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·46 lines (41 loc) · 1.44 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
#!/bin/bash
# Ref: https://qiita.com/yutkat/items/c6c7584d9795799ee164#%E3%82%B7%E3%83%B3%E3%83%97%E3%83%AB%E3%81%AAdotfiles%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%A9%E3%83%BC%E3%82%92%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86
set -ue
link_to_homedir() {
command echo "backup old dotfiles..."
if [ ! -d "$HOME/.dotbackup" ];then
command echo "$HOME/.dotbackup not found. Auto Make it"
command mkdir "$HOME/.dotbackup"
fi
local dotdir=$1
if [[ "$HOME" != "$dotdir" ]];then
for f in $dotdir/.??*; do
[[ `basename $f` == ".git*" ]] && continue
if [[ -L "$HOME/`basename $f`" ]];then
command rm -f "$HOME/`basename $f`"
fi
if [[ -e "$HOME/`basename $f`" ]];then
command mv "$HOME/`basename $f`" "$HOME/.dotbackup"
fi
command ln -snf $f $HOME
command echo "create symboliclink $f"
done
else
command echo "same install src dest"
fi
}
set_global_gitignore() {
if [ ! -d "$HOME/.config/git" ];then
command echo "$HOME/.config/git not found. Auto Make it"
command mkdir -p "$HOME/.config/git"
fi
if [[ -e "$HOME/.config/git/ignore" ]];then
command mv "$HOME/.config/git/ignore" "$HOME/.config/git/ignore.backup"
fi
local dotdir=$1
command cp $dotdir/.gitignore_global $HOME/.config/git/ignore
}
dotdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
link_to_homedir $dotdir
set_global_gitignore $dotdir
command echo "Install completed!!!!"