-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·72 lines (59 loc) · 2.24 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
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
[[ ! -z "${privatedotfiles}" ]] && installdir="$HOME/dotfiles" || installdir="$HOME"
export dt=`date +"%Y%m%d_%H%M%S"`
UsageStatement(){
echo "install.sh (update)"
echo ""
echo "install.sh has a single argument accepted. If the argument \"update\" is present, the script will first \
update the git repository found at \$HOME/publicdotfiles."
}
if [[ ! -z "$1" ]]; then
if [[ `echo ${1} | tr "[:upper:]" "[:lower:]"` = "terminal" ]]; then
cp -p ~/Library/Preferences/com.apple.Terminal.plist ~/Library/Preferences/com.apple.Terminal.plist.${dt}
cp ~/publicdotfiles/com.apple.Terminal ~/Library/Preferences/com.apple.Terminal.plist
defaults read ~/Library/Preferences/com.apple.Terminal.plist
else
UsageStatement
exit 3
fi
fi
AddToProfile(){
fileloc="$HOME/$1"
[[ ! -f ${fileloc} ]] && return 1
if [[ ! `grep 'Adding reference to standard .profile' ${fileloc}` ]]; then
echo " Adding reference to standard .profile in ${fileloc}"
echo ". $HOME/.profile.k3st" >> ${fileloc}
addedtoprofile="true"
fi
}
export source_dir="${installdir}/publicdotfiles"
UpdateLink(){
source_file="${source_dir}/$1"
target_file="$2/$1"
echo "Reviewing what to do about: ${source_file}"
if [[ "`readlink ${target_file}`" = "${source_file}" ]]; then
echo "${target_file} already set to ${source_file}, taking no action."
echo ""; echo ""
return 0
elif [[ -f "${target_file}" ]]; then
echo "${target_file} exists, and is not linked correctly to ${source_file}. Taking no action"
echo ""; echo ""
return 1
else
echo "${target_file} is not setup correctly. Linking to ${source_file}"
ln -s "${source_file}" "${target_file}"
echo ""; echo ""
fi
if [[ "$1" = ".profile.k3st" ]]; then
addedtoprofile=""
echo " Checking whether .profile.k3st is sourced correctly."
for fl in .bashrc .bash_profile .profile
do
echo " Checking $fl"
AddToProfile $fl
[[ ! -z ${addedtoprofile} ]] && [[ "${addedtoprofile}" = "true" ]] && break
done
fi
}
UpdateLink ".profile.k3st" "$HOME"
UpdateLink ".vimrc" "$HOME"