-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·31 lines (24 loc) · 949 Bytes
/
install
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
#!/usr/bin/env bash
read -p "Do you want to install the dotfiles? " -r
if [[ ! -z ${REPLY} && ! ${REPLY} =~ ^Y|y ]]; then exit; fi
echo "Linking profile files and directories..."
dotfiles="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function link_from_home { #link_from_home (dotfile, prefix)
file=${1}
prefix=${2}
homefile=~/${prefix}$(echo $file | sed -Ee 's/[a-z]+\///')
target=$(readlink -q ${homefile})
if [[ ! -z ${target} && $(dirname ${target}) == ${dotfiles} ]]; then
echo "skipping ${homefile} since it is already linked to ${dotfiles}"
else
#rm -rf "${homefile}" 2>/dev/null
mv ${homefile} ${homefile}.backup.predotfiles 2>/dev/null
ln -s "${dotfiles}/${file}" "${homefile}"
fi
}
for file in bash_profile bashrc bash_aliases vim vim/vimrc gitignore; do
link_from_home $file "." # the original dotfiles
done
echo "Done."
echo "Run the following to activate:"
echo " cd && source .bashrc"