forked from saz/dotfiles_old
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·39 lines (32 loc) · 813 Bytes
/
install.sh
File metadata and controls
executable file
·39 lines (32 loc) · 813 Bytes
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
#!/usr/bin/env bash
##
## Intsalls the dotfiles into $HOME by softlinking them.
## Existing files are backupped.
##
sourceDir="src/_*"
##
## Links source file into target directory.
## Makes backup if target link already exists.
##
## @param $1 source script
## @param $2 target direcotry
##
function linkFile {
source="${PWD}/$1"
targetFile="${1/src\//}"
targetFile="${targetFile/_/.}"
target="${2}/${targetFile}"
# Only create backup if target is a file or directory
if [ -f "${target}" ] || [ -d "${target}" ]; then
if [ ! -L "${target}" ]; then
echo "Backing up ${target}"
mv -v "${target}" "${target}.bak"
fi
fi
ln -svf "${source}" "${target}"
}
for file in ${sourceDir}
do
linkFile "${file}" "${HOME}"
done
echo "Finished :)"