-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·41 lines (32 loc) · 949 Bytes
/
install.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
#!/bin/bash
BIN_DIR="${BIN_DIR:-$HOME/.local/bin}"
COPY="${COPY:-0}"
SCRIPTS_DIR="$(pwd)/scripts"
FORCE="${FORCE:-0}"
green() { echo -e "$(tput setaf 2)$*$(tput sgr0)"; }
yellow() { echo -e "$(tput setaf 3)$*$(tput sgr0)"; }
cyan() { echo -e "$(tput setaf 6)$*$(tput sgr0)"; }
mkdir -p "$BIN_DIR"
echo
green "Installing scripts"
find $SCRIPTS_DIR -mindepth 1 -maxdepth 1 \
| while read line; do
cd -- "$(dirname "$line")"
ORIGIN="$(pwd)/$(basename "$line")"
DEST="$BIN_DIR/$(basename "$line")"
if [ "$FORCE" == "1" ]; then
rm -f "$DEST"
fi
if [ -f "$DEST" ] || [ -d "$DEST" ]; then
cyan "Destination already exists: $DEST"
elif [ "$COPY" == "1" ]; then
green "Copying file $line to $DEST"
cp "$ORIGIN" "$DEST"
else
green "Linking file $line as $DEST"
ln -s "$ORIGIN" "$DEST"
fi
cd "$BASEDIR"
done
echo
yellow "Don't forget to add \"${BIN_DIR}\" to you PATH"