Skip to content

Instantly share code, notes, and snippets.

@antontsv
Last active March 12, 2020 05:32
Show Gist options
  • Save antontsv/f99c371d3b662a776ab1e7089bd90d9c to your computer and use it in GitHub Desktop.
Save antontsv/f99c371d3b662a776ab1e7089bd90d9c to your computer and use it in GitHub Desktop.
Setup with homeshick - https://git.io/all.files
#!/usr/bin/env bash
commands=(git)
if [ -n "$URL_SHELL_EXEC" ];then
commands+=("$URL_SHELL_EXEC")
else
commands+=(curl)
fi;
has_commands=1
for cmd in ${commands[@]};do
command -v "$cmd" 1>/dev/null 2>&1
if [ $? -ne 0 ];then
has_commands=0
echo "Required command was not found: $cmd"
fi;
done
[ $has_commands -eq 1 ] || exit 1
[ -f "$HOME/.sh/init_homeshick.extra" ] && rm "$HOME/.sh/init_homeshick.extra"
base_install_gist="https://git.io/install.files"
clone_protocol="${PROTO:-https}" # https or git
if [ "$clone_protocol" = "https" ];then
INSTALL_GITHUB_URL_PREFIX="https://github.com/";
else
INSTALL_GITHUB_URL_PREFIX="git@github.com:";
fi;
# PRIVATE_REPO_CLONE_URL can a path to a local directory [with git repo]
private_repo_url="${PRIVATE_REPO_CLONE_URL:-}"
failures=()
check_and_add_failure(){
[ $? -eq 0 ] || failures+=("$@")
}
download_and_exec(){
if [ -n "$URL_SHELL_EXEC" ];then
"$URL_SHELL_EXEC" "$base_install_gist"
else
curl -s -L "$base_install_gist" | bash
fi;
check_and_add_failure "$DOT_FILES_REPO"
}
# Homeshick & .files
echo "Downloading antontsv/.files..."
DOT_FILES_REPO="${INSTALL_GITHUB_URL_PREFIX}antontsv/.files.git" download_and_exec
# ~/bin
echo "Downloading antontsv/home.bin..."
DOT_FILES_REPO="${INSTALL_GITHUB_URL_PREFIX}antontsv/home.bin.git" DOT_FILES_CASTLE_BRANCH="master" DOT_FILES_CASTLE_NAME="home.bin" download_and_exec
if [ -n "$private_repo_url" ];then
echo "Downloading private dotfiles..."
DOT_FILES_REPO="$private_repo_url" DOT_FILES_CASTLE_BRANCH="${PRIVATE_REPO_BRANCH:-master}" DOT_FILES_CASTLE_NAME="private.files" download_and_exec
fi;
OS=$(uname -s)
# extra scripts for  Mac OS
if [ "$OS" = "Darwin" ]; then
echo "Downloading antontsv/apple.bin..."
DOT_FILES_REPO="${INSTALL_GITHUB_URL_PREFIX}antontsv/apple.bin.git" DOT_FILES_CASTLE_BRANCH="master" DOT_FILES_CASTLE_NAME="apple.bin" download_and_exec
fi;
[ -d "$HOME/bin" ] || mkdir "$HOME/bin"
source "$HOME/.profile"
# install-awesome-bash function is defined in antontsv/.files
# thus should be available after sourcing ~/.profile
if ! install-awesome-bash || [ ${#failures[@]} -ne 0 ];then
for f in "${failures[@]}";do
echo "❌ Failed to install the following repo: $f" >&2
done;
exit 1;
fi;
@antontsv
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment