dotfiles/.local/bin/setup_dotfiles.sh

31 lines
1.1 KiB
Bash
Raw Normal View History

2022-04-15 14:11:00 +02:00
#!/bin/zsh
# Set up dotfiles on a new machine.
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
local repo_address="https://schlomp.space/tastytea/dotfiles.git"
local tmp_git_command='git --git-dir=${HOME}/.dotfiles/ --work-tree=${HOME}'
if [[ -f ~/.ssh/noid_dotfiles ]]; then
2022-05-09 01:00:29 +02:00
print -P "%F{12}Using dotfiles SSH-key%f"
2022-04-15 14:11:00 +02:00
repo_address="git@schlomp.space:tastytea/dotfiles.git"
export GIT_SSH_COMMAND="ssh -i ~/.ssh/noid_dotfiles"
tmp_git_command="GIT_SSH_COMMAND=\"ssh -i ~/.ssh/noid_dotfiles\" ${tmp_git_command}"
2022-05-09 01:00:29 +02:00
else
print -P "%F{12}No dotfiles SSH-key found, using HTTP access%f"
2022-04-15 14:11:00 +02:00
fi
2022-05-09 01:00:29 +02:00
alias config=${tmp_git_command}
2022-04-15 14:11:00 +02:00
2022-05-09 01:00:29 +02:00
git clone --bare ${repo_address} ${HOME}/.dotfiles
config config --local status.showUntrackedFiles no
config config --local submodule.recurse true
print -P "%F{12}Run%f" \
"%F{13}rm ${0} &&" \
"${tmp_git_command} checkout &&" \
2022-05-09 01:51:17 +02:00
"${tmp_git_command} submodule update --init%f" \
2022-05-09 01:00:29 +02:00
"%F{12}to copy the files to your home directory.%f"
2022-04-15 14:11:00 +02:00
# TODO: [remote "origin"] needs to have
# fetch = +refs/heads/*:refs/remotes/origin/* in order for
# submodule.recurse to work, but why?