summaryrefslogtreecommitdiff
path: root/install.sh
blob: d165f5adeffb731822a7e94514ff794f253331fc (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/zsh

HOME=/home/urbain
dotdir=$HOME/dotfiles

unset dotdirs install uninstall
declare -A dotdirs install uninstall

for file in `ls -A --ignore="install.sh" --ignore="README.md" --ignore=".git"`; do
    dotdirs[$file]="$HOME/$file"
    install[$file]='ln -s $dotdir/$file $(basename $dotdirs[$file])'
    uninstall[$file]='rm -rf $dotdirs[$file]'
done

install_offlineimap() {
    ln -s $dotdir/.offlineimap/offlineimaprc .offlineimaprc
    ln -s $dotdir/.offlineimap/offlineimap.py .offlineimap.py
}

install_vim() {
    ln -s $dotdir/.vim/vimrc .vimrc
    ln -s $dotdir/.vim .vim
    ln -s $dotdir/.vim/vimrc .nvimrc
    ln -s $dotdir/.vim .nvim

    mkdir -p .vim/vimundo
}

install_mutt() {
    ln -s $dotdir/.mutt .mutt
    mkdir -p .mutt/temp
    mkdir -p .mutt/cache
    mkdir -p .mutt/cache/bodies
}

install_zsh() {
    ln -s $dotdir/.zsh/zshrc .zshrc
    ln -s $dotdir/.zsh .zsh
}

install_uzbl() {
    ln -s $dotdir/.uzbl uzbl
    cd $HOME/.local/share/uzbl
    ln -s $dotdir/.uzbl/bookmarks bookmarks
}

uninstall_offlineimap() {
    rm -f .offlineimaprc
    rm -f .offlineimap.py
}

uninstall_vim() {
    rm -rf .vim .vimrc .nvim .nvimrc
}

uninstall_zsh() {
    rm -rf .zsh .zshrc
}

uninstall_uzbl() {
    rm -rf uzbl
    rm -f $HOME/.local/share/uzbl/bookmarks
}

dotdirs[.uzbl]="$HOME/.config/uzbl"
dotdirs[.zathurarc]="$HOME/.config/zathura/zathurarc"

install[.offlineimap]='install_offlineimap'
install[.vim]='install_vim'
install[.mutt]='install_mutt'
install[.zsh]='install_zsh'
install[.uzbl]='install_uzbl'

uninstall[.offlineimap]='uninstall_offlineimap'
uninstall[.vim]='uninstall_vim'
uninstall[.zsh]='uninstall_zsh'
uninstall[.uzbl]='uninstall_uzbl'

clean_dotfiles() {
    for file in ${(@k)dotdirs}; do
	echo "Cleaning $file"
        cd $(dirname $dotdirs[$file])
        eval ${uninstall[$file]}
    done
}

install_dotfiles() {
    for file in ${(@k)dotdirs}; do
	echo "Installing $file"
        cd $(dirname $dotdirs[$file])
        eval ${install[$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
}

clean_dotfiles
install_dotfiles