-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·51 lines (43 loc) · 885 Bytes
/
init.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
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
help() {
echo "\
Dotfiles Initializer
Usage:
-w, --wet-run: Actually perform the operations
"
}
while test $# -gt 0; do
case "$1" in
-h | --help)
help
exit 0
;;
-w | --wet-run)
export WET_RUN=true
shift
;;
*)
echo "ERROR: Unrecognized argument '$1'"
help
exit 1
;;
esac
done
if [[ $WET_RUN != true ]]; then
echo "In dry-run mode"
fi
for file in .*; do
if [[ ! -d "$file" ]]; then
if [[ ! -d "$HOME/$file" ]]; then
if [[ $WET_RUN == true ]]; then
ln -s "$SCRIPT_DIR/$file" "$HOME/$file"
ls -lAh -1 "$HOME/$file"
else
echo "Would create symlink in home for '$file'"
fi
else
echo "File '$file' already exists in the home directory, skipping symlink creation"
fi
fi
done