summaryrefslogtreecommitdiff
path: root/install.sh
blob: 2b64f5e65c77f8e90685fcc1b2bc6762cbf9ca8a (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
#!/bin/bash

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

function install_dotfiles {
    echo -e "\n*** \e[1mInstalling dotfiles\e[0m ***"

    rm -rf $olddir
    mkdir -p $olddir

    listFiles=`ls --ignore="make" --ignore="README.md"`

    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

    cd $dir
    mkdir -p vim/vimundo
    mkdir -p mutt/temp
    mkdir -p mutt/cache
    mkdir -p mutt/cache/bodies
}

function clean {
    echo -e "\n*** \e[1mCleaning dotfiles\e[0m ***"
    for file in `ls`; do
        rm -rfv  ~/.$file
    done
}

function install_packages {
    sudo apt-get install ttyrec mutt msmtp offlineimap wmctrl rxvt-unicode-256color \
        tmux git gcc clang cmake make zathura feh chromium-browser zsh clang xcape
}

function update_dotfiles {
    cd $dir
    echo -e "\n*** \e[1m Updating dotfiles repository\e[0m ***"
    git fetch -q origin master
    cat <(git log --reverse --pretty=format:"-- %h %s (%cr)" -4); echo -e "\e[36m"
    output=$(git log HEAD..origin)
    if [[ ! -z $output ]]; then
        cat <(git log --reverse --pretty=format:"-- %h %s (%cr)" HEAD..origin); echo -e "\e[0m"
    else
        echo -e "-- No updates since last pull\e[0m"
    fi
}

update_dotfiles
install_dotfiles