Skip to content

Instantly share code, notes, and snippets.

@doitian doitian/setup.ps1
Last active May 5, 2020

Embed
What would you like to do?
[Windows Dotfiles Bootstrap] #windows
$PublicRepoDir = "$HOME/.dotfiles/repos/public"
$PrivateRepoDir = "$HOME/.dotfiles/repos/private"
ForEach ($repo in $PublicRepoDir, $PrivateRepoDir) {
if (Test-Path -LiteralPath $repo) {
cd $repo
git pull
} else {
git clone --depth 1 "git@github.com:doitian/dotfiles-$(Split-Path -Leaf $repo).git" $repo
}
}
$SSHPath = (Get-Command -Name 'ssh.exe').Source
[Environment]::SetEnvironmentVariable('GIT_SSH', $SSHPath, 'User')
$GitconfigTmpl = $(Get-Content "$PublicRepoDir/gitconfig.tmpl")
$GitconfigTmpl = $GitconfigTmpl -Replace "__NAME__", "ian"
$GitconfigTmpl = $GitconfigTmpl -Replace "__EMAIL__", "***"
$GitconfigTmpl = $GitconfigTmpl -Replace "__HOME__", ("$HOME" -Replace "\\", "/")
$GitconfigTmpl | Set-Content "~/.gitconfig"
Get-Content "$PublicRepoDir/gitconfig.common" | Add-Content "~/.gitconfig"
git config --global core.autocrlf input
git config --global gpg.program (Get-Command -Name 'gpg.exe').Source
cp -Force "$PublicRepoDir/default/.vimrc" "~/_vimrc"
ForEach ($f in ".ignore", ".editorconfig") {
cp -Force "$PublicRepoDir/default/$f" "~/$f"
}
mkdir -Force ~/.vim/scripts, ~/.vim/projections, ~/.vim/backup, ~/.vim/swap, ~/.vim/undo, ~/.vim/autoload
cp -Force -Recurse "$PublicRepoDir/default/.vim/scripts/*" "~/.vim/scripts"
cp -Force -Recurse "$PublicRepoDir/default/.vim/projections/*" "~/.vim/projections"
mkdir -Force ~/vimfiles/autoload
Invoke-WebRequest -UseBasicParsing -OutFile ~/vimfiles/autoload/plug.vim "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
cp -Force ~/vimfiles/autoload/plug.vim ~/.vim/autoload/plug.vim
$PSProfileDir = $(Split-Path -Parent $PROFILE)
ls "$PSProfileDir/local" | cp -Force -Destination ~/
mkdir -Force ~/.ssh
cp -Force "$PrivateRepoDir/default/.ssh/config" "~/.ssh/config"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.