-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_files.sh
More file actions
executable file
·38 lines (27 loc) · 917 Bytes
/
copy_files.sh
File metadata and controls
executable file
·38 lines (27 loc) · 917 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
#!/bin/bash
cd "$(dirname "${BASH_SOURCE}")" && source "utils.sh"
declare -a FILES_TO_COPY=(
"git/gitconfig"
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
main() {
local i=""
local sourceFile=""
local targetFile=""
for i in ${FILES_TO_COPY[@]}; do
sourceFile="$(cd .. && pwd)/$i"
targetFile="$HOME/.$(printf "%s" "$i" | sed "s/.*\/\(.*\)/\1/g")"
if [ -e "$targetFile" ]; then
ask_for_confirmation "'$targetFile' already exists, do you want to overwrite it?"
if answer_is_yes; then
rm -rf "$targetFile"
execute "cp $sourceFile $targetFile" "$targetFile → $sourceFile"
else
print_error "$targetFile → $sourceFile"
fi
else
execute "cp $sourceFile $targetFile" "$targetFile → $sourceFile"
fi
done
}
main