-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_symlinks.sh
executable file
·72 lines (61 loc) · 2.16 KB
/
make_symlinks.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
#!/bin/bash
# get user homedir
OS_VERSION=$(uname -s)
HOMEDIR=$(eval printf "~$USER")
if [ "$OS_VERSION" = "Linux" ]; then
printf "Linux system detected\n\n"
OS_BASH_FILE=$HOMEDIR/.bashrc
elif [ "$OS_VERSION" = "Darwin" ]; then
printf "MacOS system detected\n\n"
OS_BASH_FILE=$HOMEDIR/.bash_profile
else
printf "Unknown system, exiting .."
exit 0
fi
OS_VIM_FILE=$HOMEDIR/.vimrc
OS_VIM_DIR=$HOMEDIR/.vim
OS_DIRCOLORS=$HOMEDIR/.dir_colors
if [ -f "$OS_BASH_FILE" ]; then
if readlink "$OS_BASH_FILE" > /dev/null; then
printf "bashrc symlink found, unlinking...\n"
unlink $OS_BASH_FILE && printf "$OS_BASH_FILE Unlinked!\n\n"
else
printf "bashrc file found, deleting...\n"
rm -f $OS_BASH_FILE && printf "$OS_BASH_FILE Deleted!\n\n"
fi
fi
if [ -f "$OS_VIM_FILE" ]; then
if readlink "$OS_VIM_FILE" > /dev/null; then
printf "vimrc symlink found, unlinking...\n"
unlink $OS_VIM_FILE && printf "$OS_VIM_FILE Unlinked!\n\n"
else
printf "vimrc file found, deleting...\n"
rm -f $OS_VIM_FILE && printf "$OS_VIM_FILE Deleted!\n\n"
fi
fi
if [ -d "$OS_VIM_DIR" ]; then
if readlink "$OS_VIM_DIR" > /dev/null; then
printf "vim folder symlink found, unlinking...\n"
unlink $OS_VIM_DIR && printf "$OS_VIM_DIR Unlinked!\n\n"
else
printf "vim folder found, deleting...\n"
rm -rf $OS_VIM_DIR && printf "$OS_VIM_DIR Deleted!\n\n"
fi
fi
if [ -d "$OS_DIRCOLORS" ]; then
if readlink "$OS_DIRCOLORS" > /dev/null; then
printf "dir_colors symlink found, unlinking...\n"
unlink $OS_DIRCOLORS && printf "$OS_DIRCOLORS Unlinked!\n\n"
else
printf "dir_colors folder found, deleting...\n"
rm -rf $OS_DIRCOLORS && printf "$OS_DIRCOLORS Deleted!\n\n"
fi
fi
# make bashrc symlink
ln -sf $PWD/.bashrc $OS_BASH_FILE && printf "bashrc link created\n"
# make vimrc symlink
ln -sf $PWD/.vimrc $OS_VIM_FILE && printf "vimrc link created\n"
# make .vim folder symlink
ln -sf $PWD/.vim $OS_VIM_DIR && printf "vim folder link created\n"
# make .dir_colors folder symlink
ln -sf $PWD/.dir_colors $OS_DIRCOLORS && printf "dir_colors link created\n"