Skip to content

Instantly share code, notes, and snippets.

@alextercete
Last active April 24, 2024 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alextercete/73b3019dc9c057decbb2cb54cb00e88c to your computer and use it in GitHub Desktop.
Save alextercete/73b3019dc9c057decbb2cb54cb00e88c to your computer and use it in GitHub Desktop.
Install my dotfiles
param (
[Parameter(Mandatory = $true)]
[string] $gitHubUsername
)
$env:GIT_CONFIG_GLOBAL = '/dev/null'
$env:GIT_CONFIG_SYSTEM = '/dev/null'
Remove-Item -Recurse -Force $HOME\.dotfiles -ErrorAction Ignore
git clone --bare https://github.com/$gitHubUsername/dotfiles.git $HOME\.dotfiles
git --git-dir=$HOME\.dotfiles --work-tree=$HOME checkout --force
git --git-dir=$HOME\.dotfiles --work-tree=$HOME config --local status.showUntrackedFiles no
git --git-dir=$HOME\.dotfiles --work-tree=$HOME submodule update --init
git --git-dir=$HOME\.dotfiles --work-tree=$HOME remote set-url origin git@github.com:$gitHubUsername/dotfiles.git
$profileFolder = Split-Path -Parent $PROFILE
Remove-Item -Recurse -Force $profileFolder -ErrorAction Ignore
Start-Process cmd -Verb RunAs -ArgumentList "/c mklink /d $profileFolder $HOME\.config\powershell"
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: dotfiles.sh <github-username>"
exit 1
fi
if ! hash git 2>/dev/null; then
echo 'ERROR: Git needs to be installed!'
exit 1
fi
# Use HTTPS for cloning to avoid the SSH dependency
HOME= git clone --bare https://github.com/$1/dotfiles.git $HOME/.dotfiles
git --git-dir=$HOME/.dotfiles --work-tree=$HOME checkout --force
git --git-dir=$HOME/.dotfiles --work-tree=$HOME config --local status.showUntrackedFiles no
cd $HOME
HOME= git --git-dir=$HOME/.dotfiles --work-tree=$HOME submodule update --init
cd -
# Revert to SSH so that we can push more easily
git --git-dir=$HOME/.dotfiles --work-tree=$HOME remote set-url origin git@github.com:$1/dotfiles.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment