forked from kierzniak/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·56 lines (48 loc) · 1.31 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
53
54
55
56
#!/bin/bash
#
# Script for installing .dotfiles
#
# @package dotfiles
# @author Piotr Kierzniewski <[email protected]>
# @copyright 2014 ViewOne Sp. z o.o.
# @license http://opensource.org/licenses/MIT MIT
# @link https://github.com/kierzniak/dotfiles
# Dotfiles path
dir="${HOME}/.dotfiles"
# Get new repository
if [ ! -d "$dir" ]; then
# Clone repository if not exists
echo "Clone repository"
git clone https://github.com/kierzniak/dotfiles.git "$dir"
else
# Pull repository if exists
echo "Repository already exists in ${dir}"
echo "Pulling changes from repository"
git --work-tree="${dir}" --git-dir="${dir}"/.git pull origin master
fi
# Symlink files if .dotfiles directory exists otherwise exit script
if [ -d "$dir" ]; then
echo "Symlinking dotfiles from ${dir}"
else
echo "$dir does not exist"
exit 1
fi
# Function to symlink
link() {
from="$1"
to="$2"
echo "Linking '$from' to '$to'"
rm -f "$to"
ln -s "$from" "$to"
}
# Iterate over *.symlink files in .dotfiles directory
for location in $(find ${dir} -name '*.symlink'); do
# Remove .symlink extenstion from file
file="${location%.symlink}"
# Remove path from file
file="${file##*/}"
# Symlink with link function
link "$location" "$HOME/.$file"
done
# Change terminal settings
open "$dir/kierzniak.terminal"