-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·52 lines (42 loc) · 1.52 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
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
IGNORE=('install.sh' 'README.md' 'register.sh' 'backup*')
NO_DOT=('bin*')
containsElement () {
local e match="$1"
shift
for e; do [[ $match == $e ]] && return 0; done
return 1
}
# make the backup dir if it doesn't exist
mkdir -p backup
for FILENAME in $(find * -type f); do
# ignore certain files and folders in the repo
if containsElement $FILENAME "${IGNORE[@]}" ; then
echo $FILENAME ignored.
continue
fi
# create and store the file path for the new link
LINKNAME="$HOME/.$FILENAME"
if containsElement $FILENAME "${NO_DOT[@]}" ; then
# allow some files (or directories) to be stored without a dot
LINKNAME="$HOME/$FILENAME"
fi
if [ $FILENAME -ef $LINKNAME ]; then
printf "$(tput setaf 10)$FILENAME already linked to $LINKNAME$(tput sgr0)\n"
continue
fi
printf "$(tput setaf 4)Installing $FILENAME to $LINKNAME$(tput sgr0)\n"
if [ -e $LINKNAME ]; then
# make a backup of the file(s), with a confirm override if necessary
mkdir -p "$(dirname backup/$FILENAME)"
mv -i "$LINKNAME" "backup/$FILENAME"
fi
# make any directories necessary to install the link
mkdir -p "$(dirname $LINKNAME)"
# link the dotfile to the home directory
ln -s $(pwd)/$FILENAME $LINKNAME
done
# post dotfiles setup
mkdir -p ~/.zsh
git clone --depth=1 https:/romkatv/powerlevel10k.git $HOME/.zsh/powerlevel10k
git clone https:/zsh-users/zsh-autosuggestions $HOME/.zsh/zsh-autosuggestions