Last active
April 24, 2024 15:27
-
-
Save alextercete/73b3019dc9c057decbb2cb54cb00e88c to your computer and use it in GitHub Desktop.
Install my dotfiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected]:$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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 [email protected]:$1/dotfiles.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment