forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.bash
More file actions
36 lines (32 loc) · 1.03 KB
/
install.bash
File metadata and controls
36 lines (32 loc) · 1.03 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
#!/usr/bin/env bash
readonly MIN_BASH_REQUIRED=4
readonly SCRIPT_DIR=$(dirname $0)
readonly GLOBIGNORE=*~:.*:README*:Rakefile:$(basename $0)
if [[ ${BASH_VERSINFO[0]} < $MIN_BASH_REQUIRED ]]; then
echo -e "Error: bash ${MIN_BASH_REQUIRED}+ required. Your version: $BASH_VERSION"
exit 1
fi
cd "$SCRIPT_DIR"
replace_all=0
for file in *; do
replace=0
source="$PWD/$file"
target="$HOME/.$file"
if [[ (( -L "$target" ) || ( -e "$target" )) && !( $replace_all = 1 ) ]]; then
read -n 1 -p "$target: file exists. Replace? [ynaq]: " && echo
case $REPLY in
y) replace=1 ;;
n) echo "Skipping." && continue ;;
a) replace_all=1 ; replace=1 ;;
q) echo "Aborting." && exit 1 ;;
*) echo "Unrecognized option '$REPLY.' Skipping." && continue ;;
esac
if [[ $replace = 1 ]]; then
ln -Ff -s "$source" "$target"
echo "Replaced."
fi
else
echo "Linking $target"
ln -Ff -s "$source" "$target"
fi
done