Skip to content

Instantly share code, notes, and snippets.

@sidoh
Created April 12, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidoh/a6ac92f5355cd8f498e1a16c2b93cb70 to your computer and use it in GitHub Desktop.
Save sidoh/a6ac92f5355cd8f498e1a16c2b93cb70 to your computer and use it in GitHub Desktop.
$ cat ~/code/me/dotfiles/install.sh
#!/bin/bash
set -eo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -e ~/.oh-my-zsh ]; then
echo "Installing oh-my-zsh..."
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
fi
if [ ! -e ~/.vim/autoload ]; then
echo "Installing vim pathogen..."
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
fi
for dotfile in $(find $DIR -type f | grep -v "\/\.git\/" | grep -v "install\.sh"); do
base_dotfile=${dotfile#$DIR}
echo "Installing $base_dotfile"
skip=""
if [ -e ~/$base_dotfile ]; then
read -p "$base_dotfile already exists in ~. Overwrite?" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
skip='yes'
fi
fi
if [ -z "$skip" ]; then
mkdir -p ~/$(dirname $base_dotfile)
rm -rf ~/$base_dotfile
ln -s $dotfile ~/$base_dotfile
else
echo "skipped $base_dotfile"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment