Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/martijnarts/dotfiles. .* in my home directory
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899#!/bin/bashDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function help {echo <<EOFusage: $0 [options]
This installs all files necessary to use these dotfiles. It creates symlinks toall files in the links/ directory and copies the files from the templates/directory. It also replaces any occurrence of {{dotfiles}} in the templates bythe path to the dotfiles repository (so if you're moving it around, reinstall).
OPTIONS: -h Show this help messgae. -r Uninstall.EOF}
REMOVE=falseYES=falsewhile getopts "rh" OPTIONdo case $OPTION in r) REMOVE=true;; h) help;; esacdone
## FUNCTIONSfunction link { read -p "Do you want to link ~/.$1 to ${DIR}/files/$1? [y/N] " if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ -L ~/.$1 ]]; then echo "Symlink already present" else ln -s ${DIR}/links/$1 ~/.$1 fi fi}function copy { read -p "Do you want to copy ${DIR}/files/$1 to ~/.$1? [y/N] " if [[ $REPLY =~ ^[Yy]$ ]]; then cp ${DIR}/templates/$1 ~/.$1 sed -i -e "s/{{dotfiles}}/$(echo $DIR | sed -e 's/[\/&]/\\&/g')/g" ~/.$1 fi}function install { read -p "Do you want to run install script for ${DIR}/installs/$1 [y/N] " if [[ $REPLY =~ ^[Yy]$ ]]; then ${DIR}/installs/$1 fi}
# Removes all installed linksfunction remove_link { if [[ $(readlink ~/.$1) == "${DIR}/links/$1" ]]; then read -p "Do you want to remove ~/.$1? [y/N] " if [[ $REPLY =~ ^[Yy]$ ]]; then rm -f ~/.$1 fi fi}
## MAINfunction main { # REMOVE if $REMOVE; then for file in ${DIR}/links/*; do remove_link $(basename $file) done
exit 1 fi
# LINK/COPY for file in ${DIR}/links/*; do link $(basename $file) done for file in ${DIR}/templates/*; do copy $(basename $file) done
# CUSTOM INSTALLATIONS for file in ${DIR}/installs/*; do install $(basename $file) done
# PLUG INSTALL read -p "Do you want to install Vim plugins with Plug? [y/N] " if [[ $REPLY =~ ^[Yy]$ ]]; then vim +PlugInstall fi}main