/
mac_setup.sh
executable file
·82 lines (65 loc) · 1.49 KB
/
mac_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
#!/bin/bash
# MacSetup
#
# Greg's vim configuration for MacOS. Use it at your own risk!
#
# * Adds this folder to the system as symlink $HOME/vim
# * Replaces .vim, .viminfo, etc with syminks pointing to this folder.
if [ ! "$1" == "force" ]; then
echo "Are you sure?"
echo
echo "This script will blow away your vim configration and replace it with symlinks to the vim"
echo "configurations in this folder."
echo
echo "Take a look at this setup script first to make sure you feel"
echo "confident about this!"
echo
echo "Run '$0 force' if you want to run it anyway"
exit 0
fi
backup()
{
file="$1"
backup_file="$file~"
if [ -e ~/$file -a ! -e ~/$backup_file ]; then
echo "* Backing up ~/$file as ~/$backup_file"
cp -a ~/$file ~/$backup_file
fi
}
copy_file()
{
file="$1"
backup $file
echo "* Creating new '~/$file'"
cp $config_path/$file ~/$file
}
full_link()
{
source_path="$1"
target_link="$2"
backup $target_link
echo "* Creating ~/$target_link symlink"
if [ -e ~/$target_link ]; then
rm -rf ~/$target_link
fi
ln -s $config_path/$source_path ~/$target_link
}
link_to_config()
{
file="$1"
full_link $file $file
}
###############################################
echo
echo "Setting up unix configurations..."
echo
. get_script_path.sh
config_path=$script_path
if [ "$config_path" != "$HOME/vim/." ]; then
full_link . vim
fi
link_to_config .vim
link_to_config .viminfo
link_to_config .vimmer
link_to_config .vimrc
link_to_config .gvimrc