-
Notifications
You must be signed in to change notification settings - Fork 146
Simplistic bootstraping script
Devin Weaver edited this page Aug 5, 2015
·
1 revision
I have a bunch of castles I work with on a regular basis. Homeshick is perfect for keeping them all in sync. The only down side is when I setup a new environment. Because I have a bunch of castles it is hard for me to remember them all. I needed a list I could reference. Also not every environment gets the same castles but most get a set of defaults.
I wrote a simple bash script that I can easily download and run on a new system that will install Homeshick and allow me to choose which castles I want installed.
The upside is that by adding and managing the script in the gh-pages
branch of my main dotfiles
castle it can be ran as a one-line-er on new systems:
$ bash <(curl https://sukima.github.io/dotfiles/homeshick.sh)
Copy, Paste, and edit to your hearts content.
#!/bin/bash
# bootstrap script to install Homeshick and you preferred castles to a new
# system.
tmpfilename="/tmp/${0##*/}.XXXXX"
if type mktemp >/dev/null; then
tmpfile=$(mktemp $tmpfilename)
else
tmpfile=$(echo $tmpfilename | sed "s/XX*/$RANDOM/")
fi
trap 'rm -f "$tmpfile"' EXIT
cat <<'EOF' > $tmpfile
# Which Homeshick castles do you want to install?
#
# Each line is passed as the argument(s) to `homeshick clone`.
# Lines starting with '#' will be ignored.
#
# If you remove or comment a line that castle will NOT be installed.
# However, if you remove or comment everything, the script will be aborted.
# Plugin management
gmarik/Vundle.vim
tmux-plugins/tpm
# Main castles
sukima/dotfiles
sukima/vimrc
sukima/tmuxrc
# Private castles (commented by default)
#sukima/muttrc
#secret@example.org:securerc.git
EOF
${VISUAL:-vi} $tmpfile
code=$?
if [[ $code -ne 0 ]]; then
echo "Editor returned ${code}." 1>&2
exit 1
fi
castles=()
while read line; do
castle=$(echo "$line" | sed '/^[ \t]*#/d;s/^[ \t]*\(.*\)[ \t]*$/\1/')
if [[ -n $castle ]]; then
castles+=("$castle")
fi
done <$tmpfile
if [[ ${#castles[@]} -eq 0 ]]; then
echo "No castles to install. Aborting."
exit 0
fi
if [[ ! -f $HOME/.homesick/repos/homeshick/homeshick.sh ]]; then
git clone git://github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick
fi
source $HOME/.homesick/repos/homeshick/homeshick.sh
for castle in "${castles[@]}"; do
homeshick clone "$castle"
done