-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·53 lines (42 loc) · 1.33 KB
/
setup
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
52
53
#!/bin/sh
# Install all dotfiles into the home directory
DOTFILESDIRREL=$(dirname "$0")
cd "$DOTFILESDIRREL/.." || exit
DOTFILESDIR=$(pwd -P)
# Initialize submodules
git -C "$DOTFILESDIR" submodule update --init
[ "$(uname -s)" = "Darwin" ] && export MACOS=1 && export UNIX=1
[ "$(uname -s)" = "Linux" ] && export LINUX=1 && export UNIX=1
uname -s | grep -q "_NT-" && export WINDOWS=1
XDG_CONFIG_DIR=$HOME/.config
if [ $UNIX ]
then
mkdir -p "$HOME/.config"
fi
for DOTFILE in *; do
HOMEFILES=("$HOME/.$DOTFILE")
[ -d "$DOTFILE" ] && DOTFILE="$DOTFILE/"
DIRFILE="$DOTFILESDIR/$DOTFILE"
echo "$DOTFILE" | grep -E -q '(^script/$|^docs/$|\.txt$|\.md$)' && continue
echo "$DOTFILE" | grep -E -q '(^karabiner/$|^espanso/$)' &&
HOMEFILES=("$XDG_CONFIG_DIR/${DOTFILE%/}")
# vim and neovim read the same configuration from different paths
echo "$DOTFILE" | grep -E -q '(^vim/$)' &&
HOMEFILES+=("$XDG_CONFIG_DIR/nvim")
echo "$DOTFILE" | grep -q '\.sh' &&
HOMEFILES=("$HOME/.$(echo "$DOTFILE" | sed -e 's/\.sh//')")
for HOMEFILE in ${HOMEFILES[@]}; do
if [ $UNIX ]
then
if [ -L "$HOMEFILE" ] && ! [ -d "$DOTFILE" ]
then
ln -sfv "$DIRFILE" "$HOMEFILE"
else
rm -rv "$HOMEFILE"
ln -sv "$DIRFILE" "$HOMEFILE"
fi
else
cp -rv "$DIRFILE" "$HOMEFILE"
fi
done
done