From 8df9472e0cdbab0d12211c2bc77918e8f515c409 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Sat, 8 Aug 2015 20:08:42 +0200 Subject: Improve installation and organization --- install.sh | 114 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 44 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index 4417d91..1c358e5 100755 --- a/install.sh +++ b/install.sh @@ -1,42 +1,81 @@ -#!/bin/bash +#!/bin/zsh -home=/home/urbain -dir=$home/dotfiles -olddir=$home/dotfiles_old +HOME=/home/urbain +dotdir=$HOME/dotfiles -function install_dotfiles { - echo -e "\n*** \e[1mInstalling dotfiles\e[0m ***" +unset dotdirs install uninstall +declare -A dotdirs install uninstall - rm -rf $olddir - mkdir -p $olddir +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 - listFiles=`ls --ignore="make" --ignore="README.md"` +install_offlineimap() { + ln -s $dotdir/.offlineimap/offlineimaprc .offlineimaprc + ln -s $dotdir/.offlineimap/offlineimap.py .offlineimap.py +} - 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 +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 +} - cd $dir - mkdir -p vim/vimundo - 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 +} - cd ~/.config/zathura/ - ln -s /home/urbain/dotfiles/zathurarc +uninstall_offlineimap() { + rm -f .offlineimaprc + rm -f .offlineimap.py } -function clean { - echo -e "\n*** \e[1mCleaning dotfiles\e[0m ***" - for file in `ls`; do - rm -rfv ~/.$file +uninstall_vim() { + rm -rf .vim .vimrc .nvim .nvimrc +} + +uninstall_zsh() { + rm -rf .zsh .zshrc +} + +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' + +uninstall[.offlineimap]='uninstall_offlineimap' +uninstall[.vim]='uninstall_vim' +uninstall[.zsh]='uninstall_zsh' + +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 } @@ -45,18 +84,5 @@ function install_packages { 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 +clean_dotfiles install_dotfiles -- cgit v1.2.3