Last active
October 22, 2023 01:00
-
-
Save augustohp/0b0f96249e399d4ec731830280fbe776 to your computer and use it in GitHub Desktop.
Homeshick bootstrap script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Author: Devin Waever <https://github.com/sukima> | |
# Author: Augusto Pascutti <[email protected]> | |
# Original source: https://github.com/sukima/dotfiles/blob/gh-pages/homeshick.sh | |
# For Windows : https://gist.github.com/augustohp/15183d64bcba18a9a773b7402ea63801 | |
# Fork source : https://gist.github.com/augustohp/0b0f96249e399d4ec731830280fbe776 | |
# | |
# Installs homeshick and clones castles of interest | |
# Usage: bash <(curl -Ls https://git.io/fNMTH) | |
set -eo pipefail | |
GIT=$(which git) | |
tmpfilename="/tmp/${0##*/}.XXXXX" | |
test -z "$GIT" && { echo "Error: Git is not installed."; exit 2; } | |
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. | |
# Git must be able to access these repositories, if you put private | |
# repositories on the list be sure to have access configured. | |
# You can CTRL-Z, do it, and `fg` to come back and complete the process. | |
# | |
# 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 | |
[email protected]:augustohp/warwick.git | |
[email protected]:augustohp/warwick-vim.git | |
[email protected]:augustohp/ore-docker-php.git | |
[email protected]:augustohp/ore-gitlab_cli.git | |
EOF | |
${VISUAL:-vi} $tmpfile | |
code=$? | |
if [[ $code -ne 0 ]]; then | |
echo "Editor returned ${code}." 1>&2 | |
exit 2 | |
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 | |
echo "Homeshick not found, installing it..." | |
mkdir -p $HOME/.homesick/repos/ | |
$GIT clone [email protected]:andsens/homeshick.git $HOME/.homesick/repos/homeshick | |
fi | |
source $HOME/.homesick/repos/homeshick/homeshick.sh | |
for castle in "${castles[@]}"; do | |
homeshick clone --force "$castle" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment