-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·46 lines (35 loc) · 1.18 KB
/
install.sh
File metadata and controls
executable file
·46 lines (35 loc) · 1.18 KB
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
#! /bin/sh
SCRIPT_PATH="$PWD/`dirname $0`"
GLOBAL_FILES_NAME="files"
GLOBAL_FOLDERS_NAME="folders"
GLOBAL_BIN_FOLDER="bin"
GLOBAL_FILES=`find ${SCRIPT_PATH}/${GLOBAL_FILES_NAME} -type f|grep -oE "[^/]+$"|tr '\n' ' '`
GLOBAL_FOLDERS=`find ${SCRIPT_PATH}/${GLOBAL_FOLDERS_NAME} -type d -maxdepth 1 -mindepth 1|grep -oE "[^/]+$"|tr '\n' ' '`
ALL_FILES="${GLOBAL_FILES} ${GLOBAL_FOLDERS}"
BIN_FILES=`echo ${SCRIPT_PATH}/${GLOBAL_BIN_FOLDER}/*`
#########################################
## Creating Links
#########################################
for file in ${ALL_FILES}
do
res=`find ~ -name "${file}" -maxdepth 1`
if [[ "$res" != "" ]]; then
echo "backing up $res into ${res}.mine"
mv -n "$res" "${res}.mine"
fi
isFolder=`echo "$GLOBAL_FOLDERS"|grep "$file"`
if [[ "$isFolder" != "" ]]; then
folder=${GLOBAL_FOLDERS_NAME}
else
folder=${GLOBAL_FILES_NAME}
fi
ln -sf "${SCRIPT_PATH}/${folder}/$file" ~/$file
done
#########################################
## Copying to /usr/local/bin
#########################################
if [[ -x "/opt/homebrew/bin/" ]]; then
cp ${BIN_FILES} /opt/homebrew/bin/
elif [[ -x "/usr/local/bin" ]]; then
cp ${BIN_FILES} /usr/local/bin
fi