Skip to content

Instantly share code, notes, and snippets.

@NickCrew
Created August 23, 2021 00:45
Show Gist options
  • Save NickCrew/33e4d509c5acc7c4d96ec69dcc9d5a54 to your computer and use it in GitHub Desktop.
Save NickCrew/33e4d509c5acc7c4d96ec69dcc9d5a54 to your computer and use it in GitHub Desktop.
User Config Install
#!/usr/bin/env bash
DOTS_REMOTE="https://github.com/NickCrew/dotfiles.git"
DOTS_REPO="$HOME/.dots.git"
DOTS_BRANCH=master
git clone --bare $DOTS_REMOTE $DOTS_REPO
function cfg {
git --git-dir=$DOTS_REPO --work-tree=$HOME $@
}
mkdir -p $HOME/.config-backup
cfg checkout $DOTS_BRANCH
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
cfg checkout 2>&1 | \
egrep "\s+\." | \
awk '{print $1}' | \
xargs -I{} mv {} .config-backup/{}
fi
cfg checkout
cfg config status.showUntrackedFiles no
cfg submodule update --init --recursive
if ! command -v zsh &>/dev/null; then
sudo apt-get update && \
sudo apt-get install -y zsh
fi
if [ -z $(grep "ZDOTDIR" /etc/zsh/zshenv) ]; then
echo 'export ZDOTDIR=$HOME/.zsh' | sudo tee -a /etc/zsh/zshenv
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment