-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
100 lines (90 loc) · 1.41 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# machine specific
linux=false
darwin=false
cygwin=false
mingw=false
case "$(uname)" in
Linux) linux=true;;
Darwin) darwin=true;;
CYGWIN*) cygwin=true;;
MINGW32*) mingw=true;; # work
MINGW64*) mingw=true;;
esac
cd `dirname $0`
DOT_FILES="
.amethyst
.bash_profile
.bashrc
.config/nvim/init.vim
.config/yamllint/config
.config/ripgrep/.ripgreprc
.gitconfig
.gitignore
.gvimrc
.minttyrc
.npmrc
.screenrc
.tmux.conf
.tmuxline.conf
.vimrc
.vsvimrc
.zprofile
.zshrc
"
VIMFILES=".vim"
link_dot_file () {
if [ ! -L ~/$2 ]; then
echo "Make Symlink ~/$2"
if [ -f ~/$2 -o -d ~/$2 ]; then
mv ~/$2 ~/$2.bak
fi
if $mingw; then
cp -rf $PWD/$1 ~/$2
else
mkdir -p ~/`dirname $1`
ln -s $PWD/$1 ~/$2
fi
fi
}
unlink_dot_file () {
echo "Remove Symlink ~/$1"
rm ~/$1
}
link_impl () {
if $mingw; then
$1 $VIMFILES vimfiles
# TODO .vimrcを設定して.vimのlnを外す
$1 $VIMFILES .vim
else
$1 $VIMFILES .vim
fi
for DOT_FILE in $DOT_FILES; do
$1 $DOT_FILE $DOT_FILE
done
}
link () {
link_impl link_dot_file
}
unlink () {
link_impl unlink_dot_file
}
# git bash用, 修正した変更を集める
gather () {
for DOT_FILE in $DOT_FILES; do
cp ~/$DOT_FILE $PWD/$DOT_FILE
done
}
case "$1" in
link)
link
;;
unlink)
unlink
;;
gather)
gather
;;
*)
echo "Usage: sh install.sh {link|unlink|gather}"
esac