-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_macos.sh
executable file
·75 lines (60 loc) · 1.43 KB
/
install_macos.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
#!/bin/bash
#set -x
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DST=$HOME
DOTFILES=$SCRIPT_DIR
if [ -z "$CYGWIN" ]; then
export CYGWIN=winsymlinks:native
fi
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
show_help() {
echo "$0 [-f] [-h]"
echo " -f Force overwrite"
echo " -h Show this help"
echo " -n Dry run (echo commands)"
}
force=0
dry_run=0
while getopts "h?fn" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
f) force=1
;;
n) dry_run=1
;;
esac
done
LN="ln -s"
[ $force -eq 0 ] || LN="$LN -f"
[ $dry_run -eq 0 ] || LN="echo $LN"
SYSNAME=`lowercase \`uname\``
case "$SYSNAME" in
cygwin*) SYSNAME=cygwin ;;
esac
[ -d $DST ] || mkdir $DST
for file in $DOTFILES/files/*; do
source=`grealpath --relative-to=$DST $file`
target=`basename $file`
$LN $source $DST/.$target
done
[ -d $DST/bin ] || mkdir $DST/bin
if [ -d $DOTFILES/bin ]; then
for file in `find $DOTFILES/bin -maxdepth 1 -type f -print`; do
source=`grealpath --relative-to=$DST $file`
target=`basename $file`
$LN $source $DST/bin/$target
done
fi
if [ -d $DOTFILES/bin/$SYSNAME ]; then
for file in `find $DOTFILES/bin/$SYSNAME -type f -print`; do
source=`grealpath --relative-to=$DST $file`
target=`basename $file`
$LN $source $DST/bin/$target
done
fi
# vim:ts=2:sw=2:et:tw=0: