From 1c65bc1f98bedacaa40cad62d50bad3af1dbc2f1 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Fri, 5 Jun 2015 15:34:27 +0100 Subject: updated install script --- install.sh | 146 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 85 insertions(+), 61 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index 24259b3..f679a42 100755 --- a/install.sh +++ b/install.sh @@ -1,78 +1,102 @@ #!/bin/bash +home=/home/urbain dir=~/dotfiles olddir=~/dotfiles_old -home=/home/urbain -rm -rf $olddir -mkdir -p $olddir +install_dotfiles=0 +install_repos=0 +install_aux=0 + +while [[ $# > 0 ]] +do + key="$1" + echo $key + case $key in + -d|--dotfiles) + install_dotfiles=1 + ;; + -r|--repositories) + install_repos=1 + ;; + -l|--lib) + install_aux=1 + ;; + *) + ;; + esac + shift +done + +if [[ "$install_dotfiles" -eq "1" ]]; then + + echo -e "\n*** Installing dotfiles ***" -echo -e "\n*** Symlinking files *** \n" -if [ $# -eq 0 ]; then + rm -rf $olddir + mkdir -p $olddir + 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 + 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 + cd $dir + mkdir -p nvim/vimundo + mkdir -p mutt/temp + mkdir -p mutt/cache + mkdir -p mutt/cache/bodies 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 +if [[ "$install_repos" -eq "1" ]]; then + echo -e "\n *** Updating/Creating git repositories ***" + + 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 + repos[uvaes]=$home/git/fuzzy-zsh-marks + repos[alols]=$home/xcape + + 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'` + mkdir -p $parentDir; cd $parentDir + echo "Cloning $githubDir in $parentDir..." + git clone -q $githubDir >> /dev/null + else + cd $thisDir + echo "Updating git repository stored in $thisDir" + git pull -q origin master >> /dev/null + cat <(git log --pretty=format:"-- %h %s (%cr)" "ORIG_HEAD...HEAD") + fi + done + + # Installing vim-plug vim package manager + cd $dir/nvim + if [ -e autoload ]; then + rm -rf autoload fi -done + mkdir -p autoload + ln -s $dir/nvim/vim-plug/plug.vim $dir/nvim/autoload/plug.vim +fi -# Installing vim-plug vim package manager -cd $dir/nvim -if [ -e autoload ]; then - rm -rf autoload +# Creating auxiliary files +if [[ "$install_aux" -eq "1" ]]; then + echo "Nothing to do for -a" fi -mkdir -p autoload -ln -s $dir/nvim/vim-plug/plug.vim $dir/nvim/autoload/plug.vim -sudo pip install neovim - -# Creating auxiliary files for mutt -cd $dir -mkdir -p nvim/vimundo -mkdir -p mutt/temp -mkdir -p mutt/cache -mkdir -p mutt/cache/bodies echo -e "\n*** Installation successful *** \n" -- cgit v1.2.3