This can happen in cases where we use a devcontainer which already has a gitconfig in the user home folder. In that case, apply the most important settings and let the rest remain for what it is. This happens with, for example, devpod.
50 lines
1.2 KiB
Bash
Executable file
50 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
function do_stow() {
|
|
local package="$1"
|
|
local opts=( "--dotfiles" "--dir" "${DOTFILES_DIR}" )
|
|
|
|
if [[ "$#" -ge 2 ]]; then
|
|
opts+=( "--target" "$2" )
|
|
fi
|
|
|
|
stow "${opts[@]}" "$package"
|
|
}
|
|
|
|
function basic_git_setup() {
|
|
if ! command -v git &> /dev/null; then
|
|
echo "[!] Git is not installed! Not running git setup."
|
|
return 1
|
|
fi
|
|
|
|
git config --global user.name "Hans Goor"
|
|
git config --global user.email "me@eyedevelop.org"
|
|
git config --global push.autoSetupRemote true
|
|
git config --global pull.rebase true
|
|
git config --global commit.gpgsign true
|
|
git config --global merge.ff no
|
|
git config --global init.defaultBranch main
|
|
}
|
|
|
|
set -eo pipefail
|
|
|
|
DOTFILES_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
|
|
TARGET_DIR="${HOME}"
|
|
|
|
if ! command -v stow &> /dev/null; then
|
|
echo "[!] Stow is not installed!"
|
|
exit 1
|
|
fi
|
|
|
|
# Make sure directories exist.
|
|
mkdir -p "${TARGET_DIR}/.ssh"
|
|
mkdir -p "${TARGET_DIR}/.config"
|
|
|
|
# Install SSH separately, as it requres a different target.
|
|
do_stow ssh "${TARGET_DIR}/.ssh" || true
|
|
do_stow tmux || true
|
|
do_stow git || (basic_git_setup || true)
|
|
do_stow zsh || true
|
|
do_stow nvim "${TARGET_DIR}/.config" || true
|
|
|
|
echo "[+] Installed!"
|