Skip to content

Instantly share code, notes, and snippets.

@guyfleeman
Last active March 8, 2022 19:10
Show Gist options
  • Save guyfleeman/e898f339fc4d20d3fa40840af1577c46 to your computer and use it in GitHub Desktop.
Save guyfleeman/e898f339fc4d20d3fa40840af1577c46 to your computer and use it in GitHub Desktop.
Dotfiles V2 Setup
has_prereqs=true
if ! command -v git &> /dev/null; then
has_prereqs=false
echo "Missing git."
fi
if ! command -v wget &> /dev/null; then
has_prereqs=false
echo "Missing wget."
fi
# this isn't strictly a prereq, but we need a sane editor
if ! command -v vim &> /dev/null; then
has_prereqs=false
echo "Missing Vim."
fi
system='none'
if grep -q "Ubuntu 20.04" /etc/lsb-release; then
system='ubuntu-20.04'
echo "Detected Ubuntu 20.04 LTS"
fi
if ! $has_prereqs; then
echo "Setup prerequisites missing."
echo "Prompting for root to install setup deps."
if [ "$system" = "ubuntu-20.04" ]; then
sudo apt update
sudo apt install -y git wget vim
fi
fi
git clone --bare https://github.com/guyfleeman/dotfiles-v2.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
fi
config checkout
config config status.showUntrackedFiles no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment