-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·42 lines (33 loc) · 1.08 KB
/
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
42
#!/bin/bash
# set -e
OLD_CWD="$PWD"
ROOT_DIR="$(git rev-parse --show-toplevel)"
BACKUP_SUFFIX="${BACKUP_SUFFIX:-}"
NO_ZSH="${NO_ZSH:-}"
cd "$ROOT_DIR/dotfiles"
# create directories if neccessary
find . ! -path . -type d -exec mkdir -p "$HOME/"{} \;
# rm existing config files and link to those in the repository
if [ -z "$BACKUP_SUFFIX" ]; then
find . -type f -exec rm -f "$HOME/"{} \; -exec ln -s "$PWD/"{} "$HOME/"{} \;
else
find . -type f \( \( -exec test -f "$HOME/"{} \; -a -exec mv -n "$HOME/"{} "$HOME/"{}"$BACKUP_SUFFIX" \; \) , -exec ln -s "$PWD/"{} "$HOME/"{} \; \)
fi
cd "$OLD_CWD"
ZPLUG_HOME=${ZPLUG_HOME:-$HOME/.zplug}
if [ -z "$NO_ZSH" ]; then
# check for zplug
if [[ -e "$ZPLUG_HOME" ]]; then
echo "$ZPLUG_HOME already exists"
else
git clone https://github.com/zplug/zplug $ZPLUG_HOME
fi
# set standard shell
std_shell="$(which zsh)"
if [ -n "$std_shell" ]; then
if [ -z "$(cat /etc/passwd | grep $USER | grep zsh)" ]; then
echo "setting standard shell to $std_shell"
chsh -s $std_shell
fi
fi
fi