-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·50 lines (41 loc) · 1.07 KB
/
setup.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.07 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
46
47
48
49
50
#!/bin/sh
FILES=".zshrc .oh-my-zsh .zsh-custom .config/rofi .config/i3 .config/nvim bin .emacs .emacs.d"
# Files where LINK differs from the repo path: "repo_path:link_path"
CUSTOM_LINKS="zsh/jump.zsh:.zsh/jump.zsh"
DEST=$1
if [ -z "$DEST" ]; then
DEST="$HOME"
fi
BASE=$(dirname $(readlink -f $0))
ask_install(){
LINK="$DEST/$2"
TARGET="$BASE/$1"
read -r -p "Link $LINK to $TARGET ?[y/N] " response
case $response in
[yY])
LINKDIR=$(dirname "$LINK")
if [ ! -d "$LINKDIR" ]; then
mkdir -p "$LINKDIR"
fi
if [ -e "$LINK" ]; then
read -r -p "File exists, override? [y/N]" response
case $response in
[yY])
rm -r -f "$LINK"
ln -s "$TARGET" "$LINK"
;;
esac
else
ln -s "$TARGET" "$LINK"
fi
;;
esac
}
for FILE in $FILES; do
ask_install "$FILE" "$FILE"
done
for ENTRY in $CUSTOM_LINKS; do
SRC="${ENTRY%%:*}"
DST="${ENTRY#*:}"
ask_install "$SRC" "$DST"
done