Skip to content

Instantly share code, notes, and snippets.

@jpalala
Created April 7, 2022 04:17
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 jpalala/03f23ebab280e53c9603619db8d107d3 to your computer and use it in GitHub Desktop.
Save jpalala/03f23ebab280e53c9603619db8d107d3 to your computer and use it in GitHub Desktop.
script setup for dotfile
#!/bin/bash
# Source: https://github.com/technicalpickles/pickled-vim/blob/master/script/setup
set -e
cd "$(dirname "$0")/.."
if [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
}
fi
echo "==> Creating symlinks…"
files=$(ls -A home/)
for f in $files; do
f="home/${f}"
absolute_f="$(pwd)/${f}"
home_f="${HOME}/$(basename "$f")"
if [[ -e ${home_f} ]]; then
if [[ -L $home_f ]]; then
home_f_target="$(greadlink -f "$home_f")"
if [[ "${home_f_target}" == "${absolute_f}" ]]; then
echo "${home_f} ok"
else
echo "${home_f} exists and symlink to ${home_f_target}. Move out of the way and run again."
fi
elif [[ -f $f ]]; then
if [[ -f $home_f ]]; then
echo "$home_f exists and is a file. Move out of the way and run again"
continue
fi
elif [[ -d $f ]]; then
if [[ -d $home_f ]]; then
echo "$home_f exists and is a file. Move out of the way and run again"
continue
fi
fi
else
echo "${home_f} -> ${absolute_f}"
ln -s "${absolute_f}" "${home_f}"
fi
done
script/bootstrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment