summaryrefslogtreecommitdiff
path: root/install.sh
blob: a68cd4033f19c9c9093c67c78f8fbdc9c2da58a7 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash

dir=~/dotfiles
olddir=~/dotfiles_old
home=/home/urbain

rm -rf $olddir
mkdir -p $olddir

echo -e "\n*** Symlinking files *** \n"

if [ $# -eq 0 ]; then
    listFiles=`ls --ignore="make" --ignore="tex" --ignore="README.md"`
else
    listFiles=$@
fi

cd $dir
for file in $listFiles; do
    if [ -e ~/.$file ]; then
        mv ~/.$file $olddir
        printf '~/.%-15s exists. ' $file
        echo -n "Moving it to $olddir. "
    fi
    ln -s $dir/$file ~/.$file
    echo "(Re)-creating symbolic link of $file."
done

if [ $# -ne 0 ]; then
    exit
fi

# Symlink for neovim
# rm ~/.nvim ~/.nvimrc
# ln -s $dir/vim ~/.nvim
# ln -s $dir/vimrc ~/.nvimrc

echo -e "\n*** Updating/Creating git repositories *** \n"

declare -A repos
repos[altercation]=$home/.solarized/mutt-colors-solarized
repos[Anthony25]=$home/.solarized/gnome-terminal-colors-solarized
repos[seebi]=$home/.solarized/dircolors-solarized
repos[gmarik]=$home/.vim/bundle/vundle
repos[junegunn]=$home/.nvim/vim-plug
repos[tmux-plugins]=$home/.tmux/plugins/tpm

for author in "${!repos[@]}"; do
    thisDir=${repos[$author]}
    if [ ! -d $thisDir ]; then
        parentDir=`echo $thisDir | sed 's/\/[^\/]\+$//g'`
        githubDir=https://github.com/$author`echo $thisDir | sed 's/.*\(\/[^\/]\+\)$/\1/g'`
        echo $githubDir
        mkdir -p $parentDir; cd $parentDir
        git clone $githubDir
    else
        cd $thisDir
        git pull origin master
    fi
done

# Installing autoload package manager 
cd $dir/nvim
if [ -e autoload ]; then
    rm -rf autoload
fi
mkdir -p autoload
ln -s $dir/nvim/vim-plug/plug.vim $dir/nvim/autoload/plug.vim

# Creating temporary file for mutt
cd $dir
mkdir -p mutt/temp

echo -e "\n*** Installation successful *** \n"