Skip to content

Instantly share code, notes, and snippets.

@bonkowski
Last active January 11, 2025 00:00
Show Gist options
  • Save bonkowski/6b8f7334263273bc8ad8733ec9f68e78 to your computer and use it in GitHub Desktop.
Save bonkowski/6b8f7334263273bc8ad8733ec9f68e78 to your computer and use it in GitHub Desktop.
Setup script
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
DOTFILE_DIR="$HOME/.dotfiles"
TPM_DIR="$HOME/.tmux/plugins/tpm"
install_homebrew() {
if ! command -v brew &>/dev/null; then
echo "Homebrew ikke funnet. Installerer Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
}
install_packages() {
echo "Oppgraderer Homebrew og installerer nødvendige pakker..."
brew upgrade
if ! command -v git &>/dev/null; then
brew install git
fi
if ! command -v stow &>/dev/null; then
brew install stow
fi
}
clone_dotfiles_repo() {
local repo_url="[email protected]:bonkowski/.dotfiles.git"
if [ ! -d "$DOTFILE_DIR" ]; then
echo "Klone .dotfiles-repoet fra $repo_url til $DOTFILE_DIR..."
git clone "$repo_url" "$DOTFILE_DIR"
fi
}
stow_all() {
local base_dir=$1
if [ ! -d "$base_dir" ]; then
echo "Katalogen $base_dir finnes ikke!"
return 1
fi
cd "$base_dir" || {
echo "Kan ikke gå til katalogen $base_dir"
return 1
}
for dir in */; do
local dir_name="${dir%/}"
if [ "$dir_name" == ".git" ]; then
continue
fi
stow "$dir_name"
done
stow -t "$HOME/.config" .config
}
install_devbox() {
if ! command -v devbox &>/dev/null; then
echo "Devbox er ikke installert. Installerer nå..."
curl -fsSL https://get.jetify.com/devbox | bash
echo "Devbox er installert."
else
echo "Devbox er allerede installert."
fi
}
main() {
install_homebrew
install_packages
clone_dotfiles_repo
stow_all "$DOTFILE_DIR"
brew bundle --file "$HOME/Brewfile"
install_devbox
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment