Skip to content

Instantly share code, notes, and snippets.

@doitian
Last active May 5, 2020 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doitian/4c177878c3d683d87b2b0b9ce3a0fd6b to your computer and use it in GitHub Desktop.
Save doitian/4c177878c3d683d87b2b0b9ce3a0fd6b to your computer and use it in GitHub Desktop.
[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